fixes, starting to replace redstone

This commit is contained in:
Sen 2025-07-14 22:15:46 +02:00
parent 92b7214c69
commit 13b6a4e280
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
34 changed files with 109 additions and 209 deletions

View file

@ -861,21 +861,29 @@ public class Block {
return this.colorMultiplier(worldIn, pos, 0);
}
public int getWeakPower(IWorldAccess worldIn, BlockPos pos, State state, Facing side) {
return 0;
}
public boolean canProvidePower() {
return false;
}
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, State state, Entity entityIn) {
public int getWeakPower(IWorldAccess worldIn, BlockPos pos, State state, Facing side) {
return 0;
}
public int getStrongPower(IWorldAccess worldIn, BlockPos pos, State state, Facing side) {
return 0;
}
public boolean hasSignalProcessing() {
return false;
}
public int getSignal(World worldIn, BlockPos pos, int input) {
return 0;
}
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, State state, Entity entityIn) {
}
public void setBlockBoundsForItemRender() {
}
@ -926,10 +934,6 @@ public class Block {
return this.material.getMobility();
}
public float getAmbientOcclusionLightValue() {
return this.isBlockNormalCube() ? 0.2F : 1.0F;
}
public void onFallenUpon(World worldIn, BlockPos pos, Entity entityIn, float fallDistance) {
entityIn.fall(fallDistance, 1.0F);
}
@ -972,14 +976,6 @@ public class Block {
return blockIn != null && other != null ? (blockIn == other ? true : blockIn.isAssociatedBlock(other)) : false;
}
public boolean hasComparatorInputOverride() {
return false;
}
public int getComparatorInputOverride(World worldIn, BlockPos pos) {
return 0;
}
public State getStateForEntityRender(State state) {
return state;
}

View file

@ -219,12 +219,12 @@ public class BlockCake extends Block
return new Property[] {BITES};
}
public int getComparatorInputOverride(World worldIn, BlockPos pos)
public int getSignal(World worldIn, BlockPos pos, int input)
{
return (7 - ((Integer)worldIn.getState(pos).getValue(BITES)).intValue()) * 2;
}
public boolean hasComparatorInputOverride()
public boolean hasSignalProcessing()
{
return true;
}

View file

@ -97,12 +97,12 @@ public class BlockPortalFrame extends Block implements Rotatable
return this.getState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()).withProperty(ORB, Boolean.valueOf(false));
}
public boolean hasComparatorInputOverride()
public boolean hasSignalProcessing()
{
return true;
}
public int getComparatorInputOverride(World worldIn, BlockPos pos)
public int getSignal(World worldIn, BlockPos pos, int input)
{
return ((Boolean)worldIn.getState(pos).getValue(ORB)).booleanValue() ? 15 : 0;
}

View file

@ -468,12 +468,12 @@ public class BlockBrewingStand extends BlockContainer
return Items.brewing_stand;
}
public boolean hasComparatorInputOverride()
public boolean hasSignalProcessing()
{
return true;
}
public int getComparatorInputOverride(World worldIn, BlockPos pos)
public int getSignal(World worldIn, BlockPos pos, int input)
{
return Container.calcRedstone(worldIn.getTileEntity(pos));
}

View file

@ -585,12 +585,12 @@ public class BlockCauldron extends Block
return Items.cauldron;
}
public boolean hasComparatorInputOverride()
public boolean hasSignalProcessing()
{
return true;
}
public int getComparatorInputOverride(World worldIn, BlockPos pos)
public int getSignal(World worldIn, BlockPos pos, int input)
{
return ((Integer)worldIn.getState(pos).getValue(LEVEL)).intValue();
}

View file

@ -239,12 +239,12 @@ public class BlockChest extends BlockContainer implements Rotatable
return false;
}
public boolean hasComparatorInputOverride()
public boolean hasSignalProcessing()
{
return true;
}
public int getComparatorInputOverride(World worldIn, BlockPos pos)
public int getSignal(World worldIn, BlockPos pos, int input)
{
return Container.calcRedstoneFromInventory(this.getChest(worldIn, pos));
}

View file

@ -230,12 +230,12 @@ public class BlockDispenser extends BlockContainer implements Directional
return Facing.getFront(meta & 7);
}
public boolean hasComparatorInputOverride()
public boolean hasSignalProcessing()
{
return true;
}
public int getComparatorInputOverride(World worldIn, BlockPos pos)
public int getSignal(World worldIn, BlockPos pos, int input)
{
return Container.calcRedstone(worldIn.getTileEntity(pos));
}

View file

@ -197,12 +197,12 @@ public class BlockFurnace extends BlockContainer implements Rotatable
super.onBlockRemoved(worldIn, pos, state);
}
public boolean hasComparatorInputOverride()
public boolean hasSignalProcessing()
{
return true;
}
public int getComparatorInputOverride(World worldIn, BlockPos pos)
public int getSignal(World worldIn, BlockPos pos, int input)
{
return Container.calcRedstone(worldIn.getTileEntity(pos));
}

View file

@ -237,12 +237,12 @@ public class BlockHopper extends BlockContainer implements DirectionalDown
return (meta & 8) != 8;
}
public boolean hasComparatorInputOverride()
public boolean hasSignalProcessing()
{
return true;
}
public int getComparatorInputOverride(World worldIn, BlockPos pos)
public int getSignal(World worldIn, BlockPos pos, int input)
{
return Container.calcRedstone(worldIn.getTileEntity(pos));
}

View file

@ -1,30 +0,0 @@
package common.block.tech;
import common.block.Block;
import common.block.Material;
import common.entity.npc.EntityNPC;
import common.init.SoundEvent;
import common.item.CheatTab;
import common.model.Model;
import common.model.ModelProvider;
import common.util.BlockPos;
import common.util.Facing;
import common.world.State;
import common.world.World;
public class BlockJukebox extends Block {
public BlockJukebox() {
super(Material.WOOD);
this.setTab(CheatTab.TECHNOLOGY);
}
public boolean onBlockActivated(World worldIn, BlockPos pos, State state, EntityNPC playerIn, Facing side, float hitX, float hitY, float hitZ) {
if(!worldIn.client)
worldIn.playSound(worldIn.rand.pick(SoundEvent.values()), pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 1.0f);
return true;
}
public Model getModel(ModelProvider provider, String name, State state) {
return provider.getModel("jukebox_side").add().dnswe().u("jukebox_top");
}
}

View file

@ -63,11 +63,11 @@ public abstract class BlockMachine extends Block implements Rotatable, ITileEnti
worldIn.removeTileEntity(pos);
}
public boolean hasComparatorInputOverride() {
public boolean hasSignalProcessing() {
return true;
}
public int getComparatorInputOverride(World worldIn, BlockPos pos) {
public int getSignal(World worldIn, BlockPos pos, int input) {
return Container.calcRedstone(worldIn.getTileEntity(pos));
}

View file

@ -1,44 +0,0 @@
package common.block.tech;
import common.block.Block;
import common.block.Material;
import common.entity.npc.EntityNPC;
import common.init.Blocks;
import common.init.SoundEvent;
import common.item.CheatTab;
import common.util.BlockPos;
import common.util.Facing;
import common.world.State;
import common.world.World;
public class BlockNote extends Block {
public BlockNote() {
super(Material.WOOD);
this.setTab(CheatTab.TECHNOLOGY);
}
public void onNeighborBlockChange(World worldIn, BlockPos pos, State state, Block neighborBlock) {
if(worldIn.isBlockPowered(pos))
worldIn.addBlockEvent(pos, Blocks.noteblock, 0, 0);
}
public boolean onBlockActivated(World worldIn, BlockPos pos, State state, EntityNPC playerIn, Facing side, float hitX, float hitY, float hitZ) {
if(!worldIn.client)
worldIn.addBlockEvent(pos, Blocks.noteblock, 0, 0);
return true;
}
public void onBlockClicked(World worldIn, BlockPos pos, EntityNPC playerIn) {
if(!worldIn.client)
worldIn.addBlockEvent(pos, Blocks.noteblock, 0, 0);
}
public boolean onBlockEventReceived(World worldIn, BlockPos pos, State state, int eventID, int eventParam) {
worldIn.playSound(SoundEvent.NOTE, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, 3.0F);
return true;
}
public boolean isMagnetic() {
return true;
}
}

View file

@ -133,12 +133,12 @@ public class BlockRailDetector extends BlockRailBase
return SHAPE;
}
public boolean hasComparatorInputOverride()
public boolean hasSignalProcessing()
{
return true;
}
public int getComparatorInputOverride(World worldIn, BlockPos pos)
public int getSignal(World worldIn, BlockPos pos, int input)
{
if (((Boolean)worldIn.getState(pos).getValue(POWERED)).booleanValue())
{

View file

@ -123,28 +123,19 @@ public class BlockRedstoneComparator extends BlockRedstoneDiode implements ITile
BlockPos blockpos = pos.offset(enumfacing);
Block block = worldIn.getState(blockpos).getBlock();
if (block.hasComparatorInputOverride())
if (block.hasSignalProcessing())
{
i = block.getComparatorInputOverride(worldIn, blockpos);
i = block.getSignal(worldIn, blockpos, 0);
}
else if (i < 15 && block.isNormalCube())
{
blockpos = blockpos.offset(enumfacing);
block = worldIn.getState(blockpos).getBlock();
if (block.hasComparatorInputOverride())
if (block.hasSignalProcessing())
{
i = block.getComparatorInputOverride(worldIn, blockpos);
i = block.getSignal(worldIn, blockpos, 0);
}
// else if (block == Blocks.air)
// {
// EntityFrame entityitemframe = this.findItemFrame(worldIn, enumfacing, blockpos);
//
// if (entityitemframe != null)
// {
// i = entityitemframe.getItemRotation();
// }
// }
}
return i;

View file

@ -49,29 +49,6 @@ public class BlockTNT extends Block
return this.power;
}
public void onBlockAdded(AWorldServer worldIn, BlockPos pos, State state)
{
super.onBlockAdded(worldIn, pos, state);
if (worldIn.isBlockPowered(pos))
{
this.onBlockDestroyedByPlayer(worldIn, pos, state.withProperty(EXPLODE, Boolean.valueOf(true)));
worldIn.setBlockToAir(pos);
}
}
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, State state, Block neighborBlock)
{
if (worldIn.isBlockPowered(pos))
{
this.onBlockDestroyedByPlayer(worldIn, pos, state.withProperty(EXPLODE, Boolean.valueOf(true)));
worldIn.setBlockToAir(pos);
}
}
/**
* Called when this Block is destroyed by an Explosion
*/

View file

@ -4496,7 +4496,6 @@ public abstract class EntityNPC extends EntityLiving
this.removeEffect(Effect.FIRE_RESISTANCE);
this.removeEffect(Effect.FLYING);
this.removeEffect(Effect.MANA_GENERATION);
this.removeEffect(Effect.ITEM_REGENERATION);
}
else {
this.extinguish();
@ -4508,7 +4507,6 @@ public abstract class EntityNPC extends EntityLiving
this.addEffect(new StatusEffect(Effect.FIRE_RESISTANCE, Integer.MAX_VALUE, 0));
this.addEffect(new StatusEffect(Effect.FLYING, Integer.MAX_VALUE, 1));
this.addEffect(new StatusEffect(Effect.MANA_GENERATION, Integer.MAX_VALUE, 255));
this.addEffect(new StatusEffect(Effect.ITEM_REGENERATION, Integer.MAX_VALUE, 255));
}
}

View file

@ -297,4 +297,8 @@ public class EntityBullet extends Entity implements IProjectile, IObjectData {
public EntityType getType() {
return EntityType.PROJECTILE;
}
public Entity getShooter() {
return this.shooter;
}
}

View file

@ -46,7 +46,7 @@ public class EntityMissile extends EntityBullet {
protected void explode() {
this.setDead();
this.worldObj.newExplosion(this.shooter == null ? this : this.shooter, this.posX, this.posY, this.posZ, (float)this.damage, this.flames, true, false);
this.worldObj.newExplosion(this, this.posX, this.posY, this.posZ, (float)this.damage, this.flames, true, false);
}
protected void onHitBlock(BlockPos pos) {

View file

@ -107,10 +107,8 @@ import common.block.tech.BlockEnchantmentTable;
import common.block.tech.BlockFurnace;
import common.block.tech.BlockHopper;
import common.block.tech.BlockInactiveDisplay;
import common.block.tech.BlockJukebox;
import common.block.tech.BlockLever;
import common.block.tech.BlockMobSpawner;
import common.block.tech.BlockNote;
import common.block.tech.BlockNuke;
import common.block.tech.BlockPistonBase;
import common.block.tech.BlockPistonHead;
@ -618,8 +616,6 @@ public abstract class BlockRegistry {
register("brewing_stand", (new BlockBrewingStand()).setHardness(0.5F).setLightLevel(0.125F).setDisplay("Braustand"));
register("cauldron", (new BlockCauldron()).setHardness(2.0F).setDisplay("Kessel"));
register("effect_generator", (new BlockEffectGenerator()).setDisplay("Effektgenerator").setLightLevel(1.0F));
register("noteblock", (new BlockNote()).setHardness(0.8F).setDisplay("Notenblock"));
register("jukebox", (new BlockJukebox()).setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE).setDisplay("Plattenspieler"));
register("construction_table", (new BlockWorkbench(4)).setHardness(2.5F).setStepSound(SoundType.WOOD).setDisplay("Konstruktionstisch"));
register("assembly_unit", (new BlockWorkbench(5)).setHardness(2.5F).setStepSound(SoundType.WOOD).setDisplay("Fertigungseinheit"));
@ -629,8 +625,8 @@ public abstract class BlockRegistry {
register("xxlarge_chest", new BlockChest(16, 10).setDisplay("Große Truhe"));
register("xxxlarge_chest", new BlockChest(18, 14).setDisplay("Große Truhe"));
register("huge_chest", new BlockChest(22, 18).setDisplay("Große Truhe"));
register("giant_chest", new BlockChest(24, 20).setDisplay("Große Truhe"));
register("toolarge_chest", new BlockChest(24, 24).setDisplay("Große Truhe"));
register("giant_chest", new BlockChest(28, 18).setDisplay("Große Truhe"));
register("toolarge_chest", new BlockChest(32, 18).setDisplay("Große Truhe"));
register("warp_chest", (new BlockWarpChest()).setHardness(22.5F).setResistance(1000.0F).setStepSound(SoundType.STONE)
.setDisplay("Warptruhe").setLightLevel(0.5F));

View file

@ -277,7 +277,6 @@ public abstract class Blocks {
public static final BlockDoor iron_door = get("iron_door");
public static final BlockOre iron_ore = get("iron_ore");
public static final BlockTrapDoor iron_trapdoor = get("iron_trapdoor");
public static final BlockJukebox jukebox = get("jukebox");
public static final BlockDoor jungle_door = get("jungle_door");
public static final BlockFence jungle_fence = get("jungle_fence");
public static final BlockFenceGate jungle_fence_gate = get("jungle_fence_gate");
@ -359,7 +358,6 @@ public abstract class Blocks {
public static final BlockOre nichun_ore = get("nichun_ore");
public static final Block nickel_block = get("nickel_block");
public static final BlockOre nickel_ore = get("nickel_ore");
public static final BlockNote noteblock = get("noteblock");
public static final BlockStaticLiquid nukage = get("nukage");
public static final BlockNuke nuke = get("nuke");
public static final BlockDoor oak_door = get("oak_door");

View file

@ -226,8 +226,6 @@ public abstract class CraftingRegistry
add(new ItemStack(Items.assembly_unit), "----", "XXXX", "X##X", '#', Items.construction_table, '-', Items.titanium_ingot, 'X', planks);
add(new ItemStack(Items.jukebox, 1), "###", "#X#", "###", '#', planks, 'X', Items.diamond);
add(new ItemStack(Items.noteblock, 1), "###", "#X#", "###", '#', planks, 'X', Items.redstone);
add(new ItemStack(Items.bookshelf, 1), "###", "XXX", "###", '#', planks, 'X', Items.book);
add(new ItemStack(Items.trapdoor, 2), "###", "###", '#', planks);
add(new ItemStack(Items.sign, 3), "###", "###", " X ", '#', planks, 'X', Items.stick);

View file

@ -458,7 +458,6 @@ public abstract class Items {
public static final ItemShovel iron_shovel = get("iron_shovel");
public static final ItemSword iron_sword = get("iron_sword");
public static final ItemBlock iron_trapdoor = get("iron_trapdoor");
public static final ItemBlock jukebox = get("jukebox");
public static final ItemDoor jungle_door = get("jungle_door");
public static final ItemFence jungle_fence = get("jungle_fence");
public static final ItemBlock jungle_fence_gate = get("jungle_fence_gate");
@ -575,7 +574,6 @@ public abstract class Items {
public static final ItemMetal nickel_ingot = get("nickel_ingot");
public static final ItemMetalBlock nickel_ore = get("nickel_ore");
public static final Item nieh_fragment = get("nieh_fragment");
public static final ItemBlock noteblock = get("noteblock");
public static final ItemBucket nukage_bucket = get("nukage_bucket");
public static final ItemBlock nuke = get("nuke");
public static final ItemDoor oak_door = get("oak_door");

View file

@ -26,7 +26,7 @@ public class ContainerChest extends Container
{
for (int k = 0; k < this.width; ++k)
{
this.addSlotToContainer(new Slot(chest, k + j * 9, 8 + k * 18, 18 + j * 18));
this.addSlotToContainer(new Slot(chest, k + j * this.width, 8 + k * 18, 18 + j * 18));
}
}

View file

@ -3,7 +3,7 @@ package common.tileentity;
import java.util.List;
import common.effect.StatusEffect;
import common.entity.types.EntityLiving;
import common.entity.npc.EntityNPC;
import common.init.Items;
import common.inventory.ContainerTile;
import common.item.ItemStack;
@ -24,7 +24,7 @@ public class DeviceEffectGenerator extends Device {
if(!this.hasAmount(0, 1) || !this.hasAmount(1, 1) || !(this.getStackInSlot(0).getItem() instanceof ItemPotion potion))
return false;
StatusEffect effect = potion.getEffect();
if(effect == null)
if(effect == null || !this.hasAmount(1, effect.getAmplifier() + 1))
return false;
int levels = 4; // TODO: energy + selector (MachineControl)
double r = (double)(levels * 10 + 10);
@ -32,9 +32,14 @@ public class DeviceEffectGenerator extends Device {
double y = this.pos.getY();
double z = this.pos.getZ();
BoundingBox bb = new BoundingBox(x + 0.5 - r, y - 16.0, z + 0.5 - r, x + 0.5 + r, (double)World.MAX_SIZE_Y, z + 0.5 + r);
List<EntityLiving> list = this.worldObj.<EntityLiving>getEntitiesWithinAABB(EntityLiving.class, bb);
for(EntityLiving entity : list) {
entity.addEffect(new StatusEffect(effect.getPotion(), 180, effect.getAmplifier()));
List<EntityNPC> list = this.worldObj.<EntityNPC>getEntitiesWithinAABB(EntityNPC.class, bb);
for(EntityNPC entity : list) {
if(!entity.hasEffect(effect.getPotion()) || entity.getEffect(effect.getPotion()).getAmplifier() < effect.getAmplifier() || entity.getEffect(effect.getPotion()).getRemaining() < 40) {
entity.addEffect(new StatusEffect(effect.getPotion(), 180, effect.getAmplifier()));
this.decrStackSize(1, effect.getAmplifier() + 1);
if(!this.hasAmount(1, effect.getAmplifier() + 1))
break;
}
}
return true;
}

View file

@ -136,7 +136,7 @@ public class TileEntityChest extends TileEntity implements ITickable, IInventory
for (int i = 0; i < nbttaglist.size(); ++i)
{
TagObject nbttagcompound = nbttaglist.get(i);
int j = nbttagcompound.getByte("Slot") & 255;
int j = nbttagcompound.getShort("Slot");
if (j >= 0 && j < this.chestContents.length)
{
@ -157,7 +157,7 @@ public class TileEntityChest extends TileEntity implements ITickable, IInventory
if (this.chestContents[i] != null)
{
TagObject nbttagcompound = new TagObject();
nbttagcompound.setByte("Slot", (byte)i);
nbttagcompound.setShort("Slot", (short)i);
this.chestContents[i].writeTags(nbttagcompound);
nbttaglist.add(nbttagcompound);
}

View file

@ -13,6 +13,7 @@ import common.entity.DamageSource;
import common.entity.Entity;
import common.entity.item.EntityTnt;
import common.entity.npc.EntityNPC;
import common.entity.projectile.EntityMissile;
import common.entity.types.EntityLiving;
import common.init.Blocks;
import common.init.SoundEvent;
@ -355,12 +356,10 @@ public class Explosion
return this.playerKnockbackMap;
}
/**
* Returns either the entity that placed the explosive block, the entity that caused the explosion or null.
*/
public EntityLiving getExplosivePlacedBy()
{
return this.exploder == null ? null : (this.exploder instanceof EntityTnt ? ((EntityTnt)this.exploder).getTntPlacedBy() : (this.exploder instanceof EntityLiving ? (EntityLiving)this.exploder : null));
return this.exploder == null ? null : (this.exploder instanceof EntityTnt ? ((EntityTnt)this.exploder).getTntPlacedBy() :
(this.exploder instanceof EntityMissile missile && missile.getShooter() instanceof EntityLiving shooter ? shooter :(this.exploder instanceof EntityLiving ? (EntityLiving)this.exploder : null)));
}
public void clearAffectedBlockPositions()

View file

@ -238,7 +238,7 @@ public abstract class World implements IWorldAccess {
if(!this.client && (flags & 1) != 0) {
this.notifyNeighborsOfStateChange(pos, iblockstate.getBlock());
if(block.hasComparatorInputOverride()) {
if(block.hasSignalProcessing()) {
this.updateComparatorOutputLevel(pos, block);
}
}
@ -1840,7 +1840,7 @@ public abstract class World implements IWorldAccess {
return iblockstate.getBlock().getStrongPower(this, pos, iblockstate, direction);
}
public int getStrongPower(BlockPos pos) {
private int getStrongPower(BlockPos pos) {
int i = 0;
i = Math.max(i, this.getStrongPower(pos.down(), Facing.DOWN));