Skip to content

Commit

Permalink
generally fix generator and research
Browse files Browse the repository at this point in the history
  • Loading branch information
khjxiaogu committed Dec 30, 2024
1 parent 1a1ff59 commit 43e02be
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public ItemStack quickMoveStack(Player playerIn, int index) {
public boolean moveItemStackTo(ItemStack pStack, int pStartIndex, int pEndIndex, boolean pReverseDirection) {
return super.moveItemStackTo(pStack, pStartIndex, pEndIndex, pReverseDirection);
}
public void reciveMessage(short btnId,int state) {
public void receiveMessage(short btnId,int state) {

}
public void sendMessage(int btnId,int state) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ public void handle(Supplier<Context> context) {
context.get().enqueueWork(()->{
Context ctx=context.get();
ServerPlayer player=ctx.getSender();
//System.out.print("received operation packet "+this);
//System.out.print("player container "+player.containerMenu.containerId+ ":"+player.containerMenu);
if(player.containerMenu.containerId==containerId&&player.containerMenu instanceof FHBaseContainer container) {
container.reciveMessage(buttonId, state);
//System.out.println("calling message received");
container.receiveMessage(buttonId, state);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,11 @@ public GeneratorContainer(MenuType<?> type, int id, Inventory inventoryPlayer, M
tempDegree.bind(() -> state.getTempMod());
rangeBlock.bind(() -> state.getRadius());
isBroken.bind(() -> data.isBroken);
isWorking.bind(() -> data.isWorking, t -> data.isWorking = t);
isWorking.bind(() -> data.isWorking, t -> {data.isWorking = t;System.out.println("set working "+t);});
isOverdrive.bind(() -> data.isOverdrive, t -> data.isOverdrive = t);

System.out.println(" binded ");
});
System.out.println(optdata);
pos.bind(() -> ctx.clickedPos());
this.validator = new Validator(ctx.clickedPos(), 8).and(ctx.mbContext().isValid());
IItemHandler handler = state.getData(FHMultiblockHelper.getAbsoluteMaster(ctx.mbContext().getLevel())).map(t -> t.inventory).orElseGet(() -> new ItemStackHandler(2));
Expand Down Expand Up @@ -108,8 +109,9 @@ public boolean mayPlace(ItemStack itemStack) {
public abstract int getTier();

public abstract FluidTank getTank();

@Override
public void receiveMessage(short btn, int state) {
//System.out.println("id "+btn+" state "+state);
switch (btn) {
case 1:
isWorking.setValue(state > 0);
Expand All @@ -118,6 +120,7 @@ public void receiveMessage(short btn, int state) {
isOverdrive.setValue(state > 0);
break;
}

/* if (message.contains("temperatureLevel", Tag.TAG_INT))
setTemperatureLevel(message.getInt("temperatureLevel"));
if (message.contains("rangeLevel", Tag.TAG_INT))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public GeneratorContainer<R, T> getMenu() {
protected List<InfoArea> makeInfoAreas() {
if (menu.getTank() == null)
return super.makeInfoAreas();
return ImmutableList.of(new FluidInfoArea(menu.getTank(), new Rect2i(135, 27, 16, 60), 0, 0, 0, 0, TEXTURE));
return ImmutableList.of(new FluidInfoArea(menu.getTank(), new Rect2i(leftPos+135,topPos+ 27, 16, 60), 0, 0, 0, 0, TEXTURE));
}
@Override
protected void drawBackgroundTexture(GuiGraphics graphics)
Expand Down Expand Up @@ -134,11 +134,11 @@ protected void renderLabels(GuiGraphics matrixStack, int x, int y) {
// this.font.drawText(matrixStack, this.playerInventory.getDisplayName(),
// this.playerInventoryTitleX, this.playerInventoryTitleY+5, 0xff404040);
// temp level
matrixStack.drawCenteredString(this.font, TemperatureDisplayHelper.toTemperatureDeltaInt(menu.tempDegree.getValue()) + "", 88, 38, 0xffffffff);
matrixStack.drawCenteredString(this.font, TemperatureDisplayHelper.toTemperatureDeltaInt(menu.tempDegree.getValue()) + "", 88, 37, 0xffffffff);
// range level
matrixStack.drawCenteredString(this.font, menu.rangeBlock.getValue() + "", 35, 41, 0xffffffff);
matrixStack.drawCenteredString(this.font, menu.rangeBlock.getValue() + "", 35, 40, 0xffffffff);
// overdrive level
matrixStack.drawCenteredString(this.font, menu.overdrive.getValue() * 100 + "", 141, 41, 0xffffffff);
matrixStack.drawCenteredString(this.font, (int)(menu.overdrive.getValue() * 100) + "", 141, 40, 0xffffffff);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public ResearchDataPacket(int committed, boolean[] flags, int level, List<ClueDa
.flag("active", o->o.active())
.flag("finished", o->o.finished()).build(),
CodecUtil.defaultValue(Codec.INT, 0).fieldOf("level").forGetter(o->o.level()),
Codec.list(ClueData.CODEC).fieldOf("clueData").forGetter(o->o.clueData()),
CodecUtil.discreteList(ClueData.CODEC).fieldOf("clueData").forGetter(o->o.clueData()),
CodecUtil.BYTE_ARRAY_CODEC.fieldOf("effectData").forGetter(o->o.effectData().toByteArray())
).apply(t, ResearchDataPacket::new));
public ResearchData(int committed, boolean[] flags, int level, Map<String, ClueData> clueData,Map<String, Boolean> effectData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public FHEffectProgressSyncPacket(TeamDataHolder team,Research rs,Effect eff) {
public void encode(FriendlyByteBuf buffer) {
buffer.writeBoolean(data);
buffer.writeVarInt(id);
buffer.writeVarInt(index);
}

public void handle(Supplier<NetworkEvent.Context> context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public <T> DataResult<T> encode(final List<A> input, final DynamicOps<T> ops, fi
int i=0;
for (final A a : input) {
final int cri=i;
if(empty.test(a))
if(!empty.test(a))
builder.add(elementCodec.encodeStart(ops, a).flatMap(o->ops.mergeToMap(o, ops.createString(index), ops.createInt(cri))));
i++;
}
Expand All @@ -58,7 +58,7 @@ public <T> DataResult<Pair<List<A>, T>> decode(final DynamicOps<T> ops, final T
final DataResult<Integer> key=ops.get(t, index).flatMap(o->ops.getNumberValue(o)).map(o->o.intValue());
element.error().ifPresent(e -> failed.add(t));
result.setValue(result.getValue().apply3((r,k, v) -> {
addEmptyIndexBefore(list,k);
addEmptyIndexBefore(list,k+1);
list.set(k,v.getFirst());
return r;
}, key, element));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
{
"type": "frostedheart:defrost_campfire",
"results": [
"frostedheart:rye_block",
"minecraft:wheat_seeds"
{
"item":"frostedheart:rye_block"
},
{
"item":"minecraft:wheat_seeds"
}
],
"ingredient": {
"item": "frostedheart:frozen_seeds"
Expand Down

0 comments on commit 43e02be

Please sign in to comment.