Compare commits

..

No commits in common. "ce972eb1f3bd0c9fd745e06619dca545a910cd9e" and "9bb1105c7c616ce13186a53dc907c79a68a05aa8" have entirely different histories.

9 changed files with 22 additions and 58 deletions

View file

@ -34,14 +34,9 @@ public class BlockBreaker extends FullyDirectionalBlock.Container {
this.isPlacer = isPlacer; this.isPlacer = isPlacer;
} }
@Override
public boolean hasTileEntity(BlockState state) {
return true;
}
@Nullable @Nullable
@Override //@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) { public TileEntity newBlockEntity(IBlockReader world) {
return this.isPlacer return this.isPlacer
? new TileEntityPlacer() ? new TileEntityPlacer()
: new TileEntityBreaker(); : new TileEntityBreaker();
@ -50,7 +45,7 @@ public class BlockBreaker extends FullyDirectionalBlock.Container {
@Override @Override
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
if (this.tryToggleRedstone(world, pos, player)) { if (this.tryToggleRedstone(world, pos, player)) {
return ActionResultType.CONSUME; return ActionResultType.PASS;
} }
return this.openGui(world, player, pos, TileEntityBreaker.class); return this.openGui(world, player, pos, TileEntityBreaker.class);

View file

@ -22,29 +22,21 @@ import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.world.IBlockReader; import net.minecraft.world.IBlockReader;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nullable;
public class BlockDropper extends FullyDirectionalBlock.Container { public class BlockDropper extends FullyDirectionalBlock.Container {
public BlockDropper() { public BlockDropper() {
super(ActuallyBlocks.defaultPickProps(0)); super(ActuallyBlocks.defaultPickProps(0));
} }
@Override //@Override
public boolean hasTileEntity(BlockState state) { public TileEntity newBlockEntity(IBlockReader worldIn) {
return true;
}
@Nullable
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
return new TileEntityDropper(); return new TileEntityDropper();
} }
@Override @Override
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) { public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
if (this.tryToggleRedstone(world, pos, player)) { if (this.tryToggleRedstone(world, pos, player)) {
return ActionResultType.CONSUME; return ActionResultType.PASS;
} }
return this.openGui(world, player, pos, TileEntityDropper.class); return this.openGui(world, player, pos, TileEntityDropper.class);

View file

@ -11,7 +11,6 @@
package de.ellpeck.actuallyadditions.mod.blocks.base; package de.ellpeck.actuallyadditions.mod.blocks.base;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
import de.ellpeck.actuallyadditions.mod.config.ConfigValues; import de.ellpeck.actuallyadditions.mod.config.ConfigValues;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityInventoryBase; import de.ellpeck.actuallyadditions.mod.tile.TileEntityInventoryBase;
@ -92,7 +91,7 @@ public abstract class BlockContainerBase extends Block {
public boolean tryToggleRedstone(World world, BlockPos pos, PlayerEntity player) { public boolean tryToggleRedstone(World world, BlockPos pos, PlayerEntity player) {
ItemStack stack = player.getMainHandItem(); ItemStack stack = player.getMainHandItem();
if (stack.getItem() == CommonConfig.Other.redstoneConfigureItem) { if (StackUtil.isValid(stack) && stack.getItem() == ConfigValues.itemRedstoneTorchConfigurator) {
TileEntity tile = world.getBlockEntity(pos); TileEntity tile = world.getBlockEntity(pos);
if (tile instanceof TileEntityBase) { if (tile instanceof TileEntityBase) {
TileEntityBase base = (TileEntityBase) tile; TileEntityBase base = (TileEntityBase) tile;
@ -132,7 +131,7 @@ public abstract class BlockContainerBase extends Block {
} }
} }
@Override //TODO do we need this? @Override
public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) { public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) {
this.neighborsChangedCustom(worldIn, pos); this.neighborsChangedCustom(worldIn, pos);
} }
@ -140,7 +139,7 @@ public abstract class BlockContainerBase extends Block {
@Override @Override
public void onNeighborChange(BlockState state, IWorldReader world, BlockPos pos, BlockPos neighbor) { public void onNeighborChange(BlockState state, IWorldReader world, BlockPos pos, BlockPos neighbor) {
super.onNeighborChange(state, world, pos, neighbor); super.onNeighborChange(state, world, pos, neighbor);
if (world instanceof World) { //TODO what? if (world instanceof World) {
this.neighborsChangedCustom((World) world, pos); this.neighborsChangedCustom((World) world, pos);
} }
} }
@ -156,8 +155,6 @@ public abstract class BlockContainerBase extends Block {
if (base.respondsToPulses()) { if (base.respondsToPulses()) {
// TODO: [port] eval what this does? :D // TODO: [port] eval what this does? :D
// world.scheduleUpdate(pos, this, this.tickRate(world)); // world.scheduleUpdate(pos, this, this.tickRate(world));
// Who knows -Flanks
base.activateOnPulse();
} }
base.setRedstonePowered(true); base.setRedstonePowered(true);
} else if (!powered && wasPowered) { } else if (!powered && wasPowered) {

View file

@ -191,16 +191,16 @@ public class ClientEvents {
if (tileHit instanceof TileEntityBase) { if (tileHit instanceof TileEntityBase) {
TileEntityBase base = (TileEntityBase) tileHit; TileEntityBase base = (TileEntityBase) tileHit;
if (base.isRedstoneToggle()) { if (base.isRedstoneToggle()) {
String strg = String.format("%s: %s", StringUtil.localize("info." + ActuallyAdditions.MODID + ".redstoneMode"), TextFormatting.DARK_RED + StringUtil.localize("info." + ActuallyAdditions.MODID + ".redstoneMode." + (base.isPulseMode String strg = String.format("%s: %s", StringUtil.localize("info." + ActuallyAdditions.MODID + ".redstoneMode.name"), TextFormatting.DARK_RED + StringUtil.localize("info." + ActuallyAdditions.MODID + ".redstoneMode." + (base.isPulseMode
? "pulse" ? "pulse"
: "deactivation")) + TextFormatting.RESET); : "deactivation")) + TextFormatting.RESET);
font.drawShadow(event.getMatrixStack(), strg, event.getWindow().getGuiScaledWidth() / 2f + 5, event.getWindow().getGuiScaledHeight() / 2f + 5, StringUtil.DECIMAL_COLOR_WHITE); font.drawShadow(event.getMatrixStack(), strg, event.getWindow().getGuiScaledWidth() / 2f + 5, event.getWindow().getGuiScaledHeight() / 2f + 5, StringUtil.DECIMAL_COLOR_WHITE);
String expl; String expl;
if (StackUtil.isValid(stack) && stack.getItem() == CommonConfig.Other.redstoneConfigureItem.asItem()) { if (StackUtil.isValid(stack) && stack.getItem() == ConfigValues.itemRedstoneTorchConfigurator) {
expl = TextFormatting.GREEN + StringUtil.localize("info." + ActuallyAdditions.MODID + ".redstoneMode.validItem"); expl = TextFormatting.GREEN + StringUtil.localize("info." + ActuallyAdditions.MODID + ".redstoneMode.validItem");
} else { } else {
expl = TextFormatting.GRAY.toString() + TextFormatting.ITALIC + StringUtil.localizeFormatted("info." + ActuallyAdditions.MODID + ".redstoneMode.invalidItem", StringUtil.localize(CommonConfig.Other.redstoneConfigureItem.asItem().getDescriptionId())); expl = TextFormatting.GRAY.toString() + TextFormatting.ITALIC + StringUtil.localizeFormatted("info." + ActuallyAdditions.MODID + ".redstoneMode.invalidItem", StringUtil.localize(CommonConfig.Other.redstoneConfigureItem.getDescriptionId() + ".name"));
} }
font.drawShadow(event.getMatrixStack(), expl, event.getWindow().getGuiScaledWidth() / 2f + 5, event.getWindow().getGuiScaledHeight() / 2f + 15, StringUtil.DECIMAL_COLOR_WHITE); font.drawShadow(event.getMatrixStack(), expl, event.getWindow().getGuiScaledWidth() / 2f + 5, event.getWindow().getGuiScaledHeight() / 2f + 15, StringUtil.DECIMAL_COLOR_WHITE);
} }

View file

@ -15,7 +15,6 @@ import com.mojang.blaze3d.systems.RenderSystem;
import de.ellpeck.actuallyadditions.mod.inventory.ContainerBreaker; import de.ellpeck.actuallyadditions.mod.inventory.ContainerBreaker;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBreaker; import de.ellpeck.actuallyadditions.mod.tile.TileEntityBreaker;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.ITextComponent;
@ -37,13 +36,6 @@ public class GuiBreaker extends AAScreen<ContainerBreaker> {
this.imageHeight = 93 + 86; this.imageHeight = 93 + 86;
} }
@Override
public void init(Minecraft pMinecraft, int pWidth, int pHeight) {
super.init(pMinecraft, pWidth, pHeight);
titleLabelX = (int) (imageWidth / 2.0f - font.width(title) / 2.0f);
titleLabelY = -10;
}
@Override @Override
protected void renderBg(@Nonnull MatrixStack matrices, float partialTicks, int x, int y) { protected void renderBg(@Nonnull MatrixStack matrices, float partialTicks, int x, int y) {
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);

View file

@ -38,10 +38,8 @@ public class GuiDropper extends AAScreen<ContainerDropper> {
} }
@Override @Override
protected void init() { public void renderLabels(@Nonnull MatrixStack matrices, int x, int y) {
super.init(); AssetUtil.displayNameString(matrices, this.font, this.imageWidth, -10, this.dropper);
titleLabelX = (int) (imageWidth / 2.0f - font.width(title) / 2.0f);
titleLabelY = -10;
} }
@Override @Override

View file

@ -13,7 +13,6 @@ package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
import de.ellpeck.actuallyadditions.mod.inventory.ContainerBreaker; import de.ellpeck.actuallyadditions.mod.inventory.ContainerBreaker;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
import de.ellpeck.actuallyadditions.mod.util.NetHandlerSpaghettiServer;
import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -30,13 +29,9 @@ import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent; import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.server.ServerWorld; import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.common.util.FakePlayerFactory;
import net.minecraftforge.fluids.IFluidBlock; import net.minecraftforge.fluids.IFluidBlock;
import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.List; import java.util.List;
@ -102,11 +97,9 @@ public class TileEntityBreaker extends TileEntityInventoryBase implements INamed
if (!this.isPlacer && blockToBreak != Blocks.AIR && !(blockToBreak instanceof IFluidBlock) && stateToBreak.getDestroySpeed(this.level, breakCoords) >= 0.0F) { if (!this.isPlacer && blockToBreak != Blocks.AIR && !(blockToBreak instanceof IFluidBlock) && stateToBreak.getDestroySpeed(this.level, breakCoords) >= 0.0F) {
List<ItemStack> drops = Block.getDrops(stateToBreak, (ServerWorld) this.level, breakCoords, this.level.getBlockEntity(breakCoords)); List<ItemStack> drops = Block.getDrops(stateToBreak, (ServerWorld) this.level, breakCoords, this.level.getBlockEntity(breakCoords));
FakePlayer fake = FakePlayerFactory.getMinecraft((ServerWorld) this.level); float chance = WorldUtil.fireFakeHarvestEventsForDropChance(this, drops, this.level, breakCoords);
if (fake.connection == null) {
fake.connection = new NetHandlerSpaghettiServer(fake); if (chance > 0 && this.level.random.nextFloat() <= chance) {
}
if (stateToBreak.canHarvestBlock(this.level, breakCoords, fake)) { //TODO might double check this is right mikey
if (StackUtil.canAddAll(this.inv, drops, false)) { if (StackUtil.canAddAll(this.inv, drops, false)) {
this.level.destroyBlock(breakCoords, false); this.level.destroyBlock(breakCoords, false);
StackUtil.addAll(this.inv, drops, false); StackUtil.addAll(this.inv, drops, false);
@ -132,10 +125,9 @@ public class TileEntityBreaker extends TileEntityInventoryBase implements INamed
this.doWork(); this.doWork();
} }
@Nonnull
@Override @Override
public ITextComponent getDisplayName() { public ITextComponent getDisplayName() {
return new TranslationTextComponent(isPlacer ? "container.actuallyadditions.placer" : "container.actuallyadditions.breaker"); return StringTextComponent.EMPTY;
} }
@Nullable @Nullable

View file

@ -27,7 +27,6 @@ import net.minecraft.util.text.StringTextComponent;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase.NBTType; import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase.NBTType;
import net.minecraft.util.text.TranslationTextComponent;
public class TileEntityDropper extends TileEntityInventoryBase implements INamedContainerProvider { public class TileEntityDropper extends TileEntityInventoryBase implements INamedContainerProvider {
@ -107,7 +106,7 @@ public class TileEntityDropper extends TileEntityInventoryBase implements INamed
@Override @Override
public ITextComponent getDisplayName() { public ITextComponent getDisplayName() {
return new TranslationTextComponent("container.actuallyadditions.dropper"); return StringTextComponent.EMPTY;
} }
@Nullable @Nullable

View file

@ -196,12 +196,11 @@ public final class WorldUtil {
if (fake.connection == null) { if (fake.connection == null) {
fake.connection = new NetHandlerSpaghettiServer(fake); fake.connection = new NetHandlerSpaghettiServer(fake);
} }
//ItemStack heldBefore = fake.getMainHandItem(); ItemStack heldBefore = fake.getMainHandItem();
setHandItemWithoutAnnoyingSound(fake, Hand.MAIN_HAND, stack.copy()); setHandItemWithoutAnnoyingSound(fake, Hand.MAIN_HAND, stack.copy());
BlockRayTraceResult ray = new BlockRayTraceResult(new Vector3d(0.5, 0.5, 0.5), side.getOpposite(), offsetPos, true); //fake.gameMode.useItemOn(fake, world, fake.getMainHandItem(), Hand.MAIN_HAND, offsetPos, side.getOpposite(), 0.5F, 0.5F, 0.5F); //TODO
fake.gameMode.useItemOn(fake, world, fake.getMainHandItem(), Hand.MAIN_HAND, ray);
ItemStack result = fake.getItemInHand(Hand.MAIN_HAND); ItemStack result = fake.getItemInHand(Hand.MAIN_HAND);
//setHandItemWithoutAnnoyingSound(fake, Hand.MAIN_HAND, heldBefore); setHandItemWithoutAnnoyingSound(fake, Hand.MAIN_HAND, heldBefore);
return result; return result;
} catch (Exception e) { } catch (Exception e) {
ActuallyAdditions.LOGGER.error("Something that places Blocks at " + offsetPos.getX() + ", " + offsetPos.getY() + ", " + offsetPos.getZ() + " in World " + world.dimension() + " threw an Exception! Don't let that happen again!", e); ActuallyAdditions.LOGGER.error("Something that places Blocks at " + offsetPos.getX() + ", " + offsetPos.getY() + ", " + offsetPos.getZ() + " in World " + world.dimension() + " threw an Exception! Don't let that happen again!", e);