Skip to content

Commit 19352d9

Browse files
committed
動作中エフェクト追加
1 parent ebd29f7 commit 19352d9

2 files changed

Lines changed: 47 additions & 1 deletion

File tree

src/main/java/com/github/gtexpert/gtbm/integration/gendustry/metatileentities/IndustrialApiaryLogic.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,25 @@ public int getCycleTickCounter() {
117117

118118
// ---- Core tick logic ----
119119

120+
private int fxTickCounter;
121+
120122
@Override
121123
public void update() {
122-
if (metaTileEntity.getWorld() == null || metaTileEntity.getWorld().isRemote) {
124+
if (metaTileEntity.getWorld() == null) return;
125+
126+
// Client-side: bee particle FX
127+
if (metaTileEntity.getWorld().isRemote) {
123128
if (wasActiveAndNeedsUpdate) {
124129
wasActiveAndNeedsUpdate = false;
125130
setActive(false);
126131
}
132+
initBeekeepingLogic();
133+
if (beekeepingLogic != null && isActive) {
134+
fxTickCounter++;
135+
if (fxTickCounter % 2 == 0 && beekeepingLogic.canDoBeeFX()) {
136+
beekeepingLogic.doBeeFX();
137+
}
138+
}
127139
return;
128140
}
129141

@@ -169,6 +181,10 @@ public void update() {
169181
// Active state
170182
if (isActive != isWorking) {
171183
setActive(isWorking);
184+
// Sync bee data to client when active state changes (for FX)
185+
if (isWorking) {
186+
apiary.syncBeeLogicToClient();
187+
}
172188
}
173189
if (wasActiveAndNeedsUpdate) {
174190
wasActiveAndNeedsUpdate = false;

src/main/java/com/github/gtexpert/gtbm/integration/gendustry/metatileentities/MetaTileEntityIndustrialApiary.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,36 @@ public boolean addProduct(ItemStack product, boolean all) {
395395
autoBreeding, this, importItems, exportItems);
396396
}
397397

398+
// ---- Bee FX sync (server→client via GT custom data) ----
399+
400+
private static final int BEE_LOGIC_SYNC_ID = 1000;
401+
402+
/**
403+
* Sync BeekeepingLogic data to client for FX rendering.
404+
* Called from IndustrialApiaryLogic when active state changes.
405+
*/
406+
public void syncBeeLogicToClient() {
407+
IBeekeepingLogic logic = getBeekeepingLogic();
408+
if (logic != null && getWorld() != null && !getWorld().isRemote) {
409+
writeCustomData(BEE_LOGIC_SYNC_ID, buf -> logic.writeData(buf));
410+
}
411+
}
412+
413+
@Override
414+
public void receiveCustomData(int dataId, net.minecraft.network.PacketBuffer buf) {
415+
super.receiveCustomData(dataId, buf);
416+
if (dataId == BEE_LOGIC_SYNC_ID) {
417+
IBeekeepingLogic logic = getBeekeepingLogic();
418+
if (logic != null) {
419+
try {
420+
logic.readData(buf);
421+
} catch (java.io.IOException e) {
422+
// Ignore sync errors
423+
}
424+
}
425+
}
426+
}
427+
398428
// ---- Accessors ----
399429

400430
protected IndustrialApiaryLogic getLogic() {

0 commit comments

Comments
 (0)