mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-18 11:19:19 +00:00
Tiny potato actions (jumping, petting, hearting) now show to others in multiplayer. Very important.
This commit is contained in:
1 parent
bda4cc70b6
commit
ab027fcab9
2 files changed
+27
-11
No files matched your search
@@ -29,6 +29,7 @@ import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import vazkii.botania.api.state.BotaniaStateProps;
|
||||
import vazkii.botania.common.block.BlockMod;
|
||||
import vazkii.botania.common.block.tile.TileSimpleInventory;
|
||||
@@ -72,8 +73,10 @@ public class BlockTinyPotato extends BlockMod {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if(tile instanceof TileTinyPotato) {
|
||||
((TileTinyPotato) tile).interact(player, hand, player.getHeldItem(hand), hit.getFace());
|
||||
AxisAlignedBB box = SHAPE.getBoundingBox();
|
||||
world.addParticle(ParticleTypes.HEART, pos.getX() + box.minX + Math.random() * (box.maxX - box.minX), pos.getY() + box.maxY, pos.getZ() + box.minZ + Math.random() * (box.maxZ - box.minZ), 0, 0 ,0);
|
||||
if(!world.isRemote) {
|
||||
AxisAlignedBB box = SHAPE.getBoundingBox();
|
||||
((ServerWorld) world).spawnParticle(ParticleTypes.HEART, pos.getX() + box.minX + Math.random() * (box.maxX - box.minX), pos.getY() + box.maxY, pos.getZ() + box.minZ + Math.random() * (box.maxZ - box.minZ), 1, 0 ,0, 0, 0);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ public class TileTinyPotato extends TileSimpleInventory implements ITickableTile
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.TINY_POTATO)
|
||||
public static TileEntityType<TileTinyPotato> TYPE;
|
||||
private static final String TAG_NAME = "name";
|
||||
private static final int JUMP_EVENT = 0;
|
||||
|
||||
public int jumpTicks = 0;
|
||||
public ITextComponent name = new StringTextComponent("");
|
||||
@@ -69,9 +70,9 @@ public class TileTinyPotato extends TileSimpleInventory implements ITickableTile
|
||||
}
|
||||
}
|
||||
|
||||
jump();
|
||||
|
||||
if(!world.isRemote) {
|
||||
jump();
|
||||
|
||||
if(name.getString().toLowerCase().trim().endsWith("shia labeouf") && nextDoIt == 0) {
|
||||
nextDoIt = 40;
|
||||
world.playSound(null, pos, ModSounds.doit, SoundCategory.BLOCKS, 1F, 1F);
|
||||
@@ -91,18 +92,30 @@ public class TileTinyPotato extends TileSimpleInventory implements ITickableTile
|
||||
|
||||
private void jump() {
|
||||
if(jumpTicks == 0)
|
||||
jumpTicks = 20;
|
||||
world.addBlockEvent(getPos(), getBlockState().getBlock(), JUMP_EVENT, 20);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean receiveClientEvent(int id, int param) {
|
||||
if(id == JUMP_EVENT) {
|
||||
jumpTicks = param;
|
||||
return true;
|
||||
} else {
|
||||
return super.receiveClientEvent(id, param);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
if(world.rand.nextInt(100) == 0)
|
||||
jump();
|
||||
|
||||
if(jumpTicks > 0)
|
||||
jumpTicks--;
|
||||
if(nextDoIt > 0)
|
||||
nextDoIt--;
|
||||
|
||||
if(!world.isRemote) {
|
||||
if(world.rand.nextInt(100) == 0)
|
||||
jump();
|
||||
if(nextDoIt > 0)
|
||||
nextDoIt--;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -137,7 +150,7 @@ public class TileTinyPotato extends TileSimpleInventory implements ITickableTile
|
||||
@Nullable
|
||||
@Override
|
||||
public ITextComponent getCustomName() {
|
||||
return name.getString().isEmpty() ? null : name; // todo 1.14 improve
|
||||
return name.getString().isEmpty() ? null : name;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
||||
Reference in new issue
Block a user