Closes #2 , remove gas containers for now
This commit is contained in:
parent
2fbb3c8ff0
commit
94f06e5501
|
@ -28,7 +28,7 @@ java {
|
|||
minecraft {
|
||||
mappings channel: 'official', version: '1.16.5'
|
||||
|
||||
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||
|
||||
runs {
|
||||
client {
|
||||
|
|
|
@ -18,16 +18,13 @@
|
|||
|
||||
package com.teammoeg.steampowered;
|
||||
|
||||
import com.teammoeg.steampowered.item.GasContainerItem;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public class ItemRegistry {
|
||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, SteamPowered.MODID);
|
||||
|
||||
public static RegistryObject<Item> pressurizedGasContainer = ITEMS.register("pressurized_gas_container", () -> new GasContainerItem(Fluids.EMPTY, (new Item.Properties()).stacksTo(16).tab(SteamPowered.itemGroup)));
|
||||
public static RegistryObject<Item> pressurizedSteamContainer = ITEMS.register("pressurized_steam_container", () -> new GasContainerItem(FluidRegistry.steam, new Item.Properties().stacksTo(1).tab(SteamPowered.itemGroup).craftRemainder(ItemRegistry.pressurizedGasContainer.get())));
|
||||
// public static RegistryObject<Item> pressurizedGasContainer = ITEMS.register("pressurized_gas_container", () -> new GasContainerItem(Fluids.EMPTY, (new Item.Properties()).stacksTo(16).tab(SteamPowered.itemGroup)));
|
||||
// public static RegistryObject<Item> pressurizedSteamContainer = ITEMS.register("pressurized_steam_container", () -> new GasContainerItem(FluidRegistry.steam, new Item.Properties().stacksTo(1).tab(SteamPowered.itemGroup).craftRemainder(ItemRegistry.pressurizedGasContainer.get())));
|
||||
}
|
||||
|
|
|
@ -81,7 +81,6 @@ public class SteamPowered {
|
|||
SPBlocks.register();
|
||||
SPTiles.register();
|
||||
SPItems.register();
|
||||
BlockStressDefaults.setDefaultImpact(new ResourceLocation("create","gantry_shaft"),32.0);
|
||||
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, SPConfig.COMMON_CONFIG);
|
||||
ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, SPConfig.SERVER_CONFIG);
|
||||
PacketHandler.register();
|
||||
|
|
|
@ -33,6 +33,7 @@ import net.minecraft.entity.LivingEntity;
|
|||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.state.BooleanProperty;
|
||||
import net.minecraft.state.DirectionProperty;
|
||||
import net.minecraft.state.StateContainer;
|
||||
|
@ -107,7 +108,7 @@ public abstract class BurnerBlock extends Block {
|
|||
pe.setItemInHand(h, cap.extractItem(0, is.getCount(), false));
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
} else if (ForgeHooks.getBurnTime(pe.getItemInHand(h)) != 0) {
|
||||
} else if (ForgeHooks.getBurnTime(pe.getItemInHand(h)) != 0 && pe.getItemInHand(h).getItem() != Items.LAVA_BUCKET) {
|
||||
IItemHandler cap = w.getBlockEntity(bp).getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).resolve().get();
|
||||
pe.setItemInHand(h, cap.insertItem(0, pe.getItemInHand(h), false));
|
||||
return ActionResultType.SUCCESS;
|
||||
|
|
|
@ -52,83 +52,83 @@ public class GasContainerItem extends BucketItem {
|
|||
super(supplier, builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack getEmptySuccessItem(ItemStack stack, PlayerEntity player) {
|
||||
return !player.abilities.instabuild ? new ItemStack(ItemRegistry.pressurizedGasContainer.get()) : stack;
|
||||
}
|
||||
// @Override
|
||||
// protected ItemStack getEmptySuccessItem(ItemStack stack, PlayerEntity player) {
|
||||
// return !player.abilities.instabuild ? new ItemStack(ItemRegistry.pressurizedGasContainer.get()) : stack;
|
||||
// }
|
||||
|
||||
public ActionResult<ItemStack> use(World p_77659_1_, PlayerEntity p_77659_2_, Hand p_77659_3_) {
|
||||
ItemStack itemstack = p_77659_2_.getItemInHand(p_77659_3_);
|
||||
RayTraceResult raytraceresult = getPlayerPOVHitResult(p_77659_1_, p_77659_2_, this.content == Fluids.EMPTY ? RayTraceContext.FluidMode.SOURCE_ONLY : RayTraceContext.FluidMode.NONE);
|
||||
ActionResult<ItemStack> ret = net.minecraftforge.event.ForgeEventFactory.onBucketUse(p_77659_2_, p_77659_1_, itemstack, raytraceresult);
|
||||
if (ret != null) return ret;
|
||||
if (raytraceresult.getType() == RayTraceResult.Type.MISS) {
|
||||
return ActionResult.pass(itemstack);
|
||||
} else if (raytraceresult.getType() != RayTraceResult.Type.BLOCK) {
|
||||
return ActionResult.pass(itemstack);
|
||||
} else {
|
||||
BlockRayTraceResult blockraytraceresult = (BlockRayTraceResult) raytraceresult;
|
||||
BlockPos blockpos = blockraytraceresult.getBlockPos();
|
||||
Direction direction = blockraytraceresult.getDirection();
|
||||
BlockPos blockpos1 = blockpos.relative(direction);
|
||||
if (p_77659_1_.mayInteract(p_77659_2_, blockpos) && p_77659_2_.mayUseItemAt(blockpos1, direction, itemstack)) {
|
||||
if (this.content == Fluids.EMPTY) {
|
||||
BlockState blockstate1 = p_77659_1_.getBlockState(blockpos);
|
||||
// public ActionResult<ItemStack> use(World p_77659_1_, PlayerEntity p_77659_2_, Hand p_77659_3_) {
|
||||
// ItemStack itemstack = p_77659_2_.getItemInHand(p_77659_3_);
|
||||
// RayTraceResult raytraceresult = getPlayerPOVHitResult(p_77659_1_, p_77659_2_, this.content == Fluids.EMPTY ? RayTraceContext.FluidMode.SOURCE_ONLY : RayTraceContext.FluidMode.NONE);
|
||||
// ActionResult<ItemStack> ret = net.minecraftforge.event.ForgeEventFactory.onBucketUse(p_77659_2_, p_77659_1_, itemstack, raytraceresult);
|
||||
// if (ret != null) return ret;
|
||||
// if (raytraceresult.getType() == RayTraceResult.Type.MISS) {
|
||||
// return ActionResult.pass(itemstack);
|
||||
// } else if (raytraceresult.getType() != RayTraceResult.Type.BLOCK) {
|
||||
// return ActionResult.pass(itemstack);
|
||||
// } else {
|
||||
// BlockRayTraceResult blockraytraceresult = (BlockRayTraceResult) raytraceresult;
|
||||
// BlockPos blockpos = blockraytraceresult.getBlockPos();
|
||||
// Direction direction = blockraytraceresult.getDirection();
|
||||
// BlockPos blockpos1 = blockpos.relative(direction);
|
||||
// if (p_77659_1_.mayInteract(p_77659_2_, blockpos) && p_77659_2_.mayUseItemAt(blockpos1, direction, itemstack)) {
|
||||
// if (this.content == Fluids.EMPTY) {
|
||||
// BlockState blockstate1 = p_77659_1_.getBlockState(blockpos);
|
||||
//
|
||||
// // ONLY STEAM ALLOWED
|
||||
// if (blockstate1.getBlock() instanceof FlowingFluidBlock) {
|
||||
// Fluid tempFluid = ((FlowingFluidBlock) blockstate1.getBlock()).getFluid();
|
||||
// boolean isSteam = tempFluid != Fluids.EMPTY && tempFluid == FluidRegistry.steam.get();
|
||||
// if (isSteam && blockstate1.getBlock() instanceof IBucketPickupHandler) {
|
||||
// Fluid fluid = ((IBucketPickupHandler) blockstate1.getBlock()).takeLiquid(p_77659_1_, blockpos, blockstate1);
|
||||
// if (fluid != Fluids.EMPTY) {
|
||||
// p_77659_2_.awardStat(Stats.ITEM_USED.get(this));
|
||||
//
|
||||
// SoundEvent soundevent = this.content.getAttributes().getFillSound();
|
||||
// if (soundevent == null)
|
||||
// soundevent = fluid.is(FluidTags.LAVA) ? SoundEvents.BUCKET_FILL_LAVA : SoundEvents.BUCKET_FILL;
|
||||
// p_77659_2_.playSound(soundevent, 1.0F, 1.0F);
|
||||
// ItemStack itemstack1 = DrinkHelper.createFilledResult(itemstack, p_77659_2_, new ItemStack(fluid.getBucket()));
|
||||
// if (!p_77659_1_.isClientSide) {
|
||||
// CriteriaTriggers.FILLED_BUCKET.trigger((ServerPlayerEntity) p_77659_2_, new ItemStack(fluid.getBucket()));
|
||||
// }
|
||||
//
|
||||
// return ActionResult.sidedSuccess(itemstack1, p_77659_1_.isClientSide());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return ActionResult.fail(itemstack);
|
||||
// } else {
|
||||
// BlockState blockstate = p_77659_1_.getBlockState(blockpos);
|
||||
// BlockPos blockpos2 = canBlockContainFluid(p_77659_1_, blockpos, blockstate) ? blockpos : blockpos1;
|
||||
// if (this.emptyBucket(p_77659_2_, p_77659_1_, blockpos2, blockraytraceresult)) {
|
||||
// this.checkExtraContent(p_77659_1_, itemstack, blockpos2);
|
||||
// if (p_77659_2_ instanceof ServerPlayerEntity) {
|
||||
// CriteriaTriggers.PLACED_BLOCK.trigger((ServerPlayerEntity) p_77659_2_, blockpos2, itemstack);
|
||||
// }
|
||||
//
|
||||
// p_77659_2_.awardStat(Stats.ITEM_USED.get(this));
|
||||
// return ActionResult.sidedSuccess(this.getEmptySuccessItem(itemstack, p_77659_2_), p_77659_1_.isClientSide());
|
||||
// } else {
|
||||
// return ActionResult.fail(itemstack);
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// return ActionResult.fail(itemstack);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// ONLY STEAM ALLOWED
|
||||
if (blockstate1.getBlock() instanceof FlowingFluidBlock) {
|
||||
Fluid tempFluid = ((FlowingFluidBlock) blockstate1.getBlock()).getFluid();
|
||||
boolean isSteam = tempFluid != Fluids.EMPTY && tempFluid == FluidRegistry.steam.get();
|
||||
if (isSteam && blockstate1.getBlock() instanceof IBucketPickupHandler) {
|
||||
Fluid fluid = ((IBucketPickupHandler) blockstate1.getBlock()).takeLiquid(p_77659_1_, blockpos, blockstate1);
|
||||
if (fluid != Fluids.EMPTY) {
|
||||
p_77659_2_.awardStat(Stats.ITEM_USED.get(this));
|
||||
// @Override
|
||||
// public net.minecraftforge.common.capabilities.ICapabilityProvider initCapabilities(ItemStack stack, @Nullable net.minecraft.nbt.CompoundNBT nbt) {
|
||||
// if (this.getClass() == GasContainerItem.class)
|
||||
// return new net.minecraftforge.fluids.capability.wrappers.FluidBucketWrapper(stack);
|
||||
// else
|
||||
// return super.initCapabilities(stack, nbt);
|
||||
// }
|
||||
|
||||
SoundEvent soundevent = this.content.getAttributes().getFillSound();
|
||||
if (soundevent == null)
|
||||
soundevent = fluid.is(FluidTags.LAVA) ? SoundEvents.BUCKET_FILL_LAVA : SoundEvents.BUCKET_FILL;
|
||||
p_77659_2_.playSound(soundevent, 1.0F, 1.0F);
|
||||
ItemStack itemstack1 = DrinkHelper.createFilledResult(itemstack, p_77659_2_, new ItemStack(fluid.getBucket()));
|
||||
if (!p_77659_1_.isClientSide) {
|
||||
CriteriaTriggers.FILLED_BUCKET.trigger((ServerPlayerEntity) p_77659_2_, new ItemStack(fluid.getBucket()));
|
||||
}
|
||||
|
||||
return ActionResult.sidedSuccess(itemstack1, p_77659_1_.isClientSide());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ActionResult.fail(itemstack);
|
||||
} else {
|
||||
BlockState blockstate = p_77659_1_.getBlockState(blockpos);
|
||||
BlockPos blockpos2 = canBlockContainFluid(p_77659_1_, blockpos, blockstate) ? blockpos : blockpos1;
|
||||
if (this.emptyBucket(p_77659_2_, p_77659_1_, blockpos2, blockraytraceresult)) {
|
||||
this.checkExtraContent(p_77659_1_, itemstack, blockpos2);
|
||||
if (p_77659_2_ instanceof ServerPlayerEntity) {
|
||||
CriteriaTriggers.PLACED_BLOCK.trigger((ServerPlayerEntity) p_77659_2_, blockpos2, itemstack);
|
||||
}
|
||||
|
||||
p_77659_2_.awardStat(Stats.ITEM_USED.get(this));
|
||||
return ActionResult.sidedSuccess(this.getEmptySuccessItem(itemstack, p_77659_2_), p_77659_1_.isClientSide());
|
||||
} else {
|
||||
return ActionResult.fail(itemstack);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return ActionResult.fail(itemstack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraftforge.common.capabilities.ICapabilityProvider initCapabilities(ItemStack stack, @Nullable net.minecraft.nbt.CompoundNBT nbt) {
|
||||
if (this.getClass() == GasContainerItem.class)
|
||||
return new net.minecraftforge.fluids.capability.wrappers.FluidBucketWrapper(stack);
|
||||
else
|
||||
return super.initCapabilities(stack, nbt);
|
||||
}
|
||||
|
||||
private boolean canBlockContainFluid(World worldIn, BlockPos posIn, BlockState blockstate) {
|
||||
return blockstate.getBlock() instanceof ILiquidContainer && ((ILiquidContainer) blockstate.getBlock()).canPlaceLiquid(worldIn, posIn, blockstate, this.content);
|
||||
}
|
||||
// private boolean canBlockContainFluid(World worldIn, BlockPos posIn, BlockState blockstate) {
|
||||
// return blockstate.getBlock() instanceof ILiquidContainer && ((ILiquidContainer) blockstate.getBlock()).canPlaceLiquid(worldIn, posIn, blockstate, this.content);
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2021 TeamMoeg
|
||||
*
|
||||
* This file is part of Steam Powered.
|
||||
*
|
||||
* Steam Powered is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* Steam Powered is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Steam Powered. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.teammoeg.steampowered.network;
|
||||
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public interface ITileSync {
|
||||
void receiveFromServer(CompoundNBT message);
|
||||
void receiveFromClient(CompoundNBT message);
|
||||
BlockPos getSyncPos();
|
||||
}
|
|
@ -42,7 +42,5 @@ public class PacketHandler {
|
|||
@SuppressWarnings("UnusedAssignment")
|
||||
public static void register() {
|
||||
int id = 0;
|
||||
|
||||
CHANNEL.registerMessage(id++, TileSyncPacket.class, TileSyncPacket::encode, TileSyncPacket::new, TileSyncPacket::handle);
|
||||
}
|
||||
}
|
|
@ -1,81 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2021 TeamMoeg
|
||||
*
|
||||
* This file is part of Steam Powered.
|
||||
*
|
||||
* Steam Powered is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* Steam Powered is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Steam Powered. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.teammoeg.steampowered.network;
|
||||
|
||||
import com.teammoeg.steampowered.client.ClientUtils;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class TileSyncPacket {
|
||||
private BlockPos pos;
|
||||
private CompoundNBT nbt;
|
||||
|
||||
public TileSyncPacket(ITileSync tile, CompoundNBT nbt) {
|
||||
this.pos = tile.getSyncPos();
|
||||
this.nbt = nbt;
|
||||
}
|
||||
|
||||
public TileSyncPacket(PacketBuffer buf) {
|
||||
this.pos = new BlockPos(buf.readInt(), buf.readInt(), buf.readInt());
|
||||
this.nbt = buf.readNbt();
|
||||
}
|
||||
|
||||
public void encode(PacketBuffer buf) {
|
||||
buf.writeInt(this.pos.getX()).writeInt(this.pos.getY()).writeInt(this.pos.getZ());
|
||||
buf.writeNbt(this.nbt);
|
||||
}
|
||||
|
||||
public void handle(Supplier<NetworkEvent.Context> context) {
|
||||
NetworkEvent.Context ctx = (NetworkEvent.Context) context.get();
|
||||
if (ctx.getDirection().getReceptionSide() == LogicalSide.SERVER) {
|
||||
ctx.enqueueWork(() -> {
|
||||
ServerWorld world = ((ServerPlayerEntity) Objects.requireNonNull(ctx.getSender())).getLevel();
|
||||
if (world.isAreaLoaded(this.pos, 1)) {
|
||||
TileEntity tile = world.getBlockEntity(this.pos);
|
||||
if (tile instanceof ITileSync) {
|
||||
((ITileSync) tile).receiveFromClient(this.nbt);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
} else {
|
||||
ctx.enqueueWork(() -> {
|
||||
World world = ClientUtils.getClientWorld();
|
||||
if (world != null) {
|
||||
TileEntity tile = world.getBlockEntity(this.pos);
|
||||
if (tile instanceof ITileSync) {
|
||||
((ITileSync) tile).receiveFromServer(this.nbt);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
ctx.setPacketHandled(true);
|
||||
}
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
public net.minecraft.item.BucketItem field_77876_a # content
|
|
@ -1,23 +0,0 @@
|
|||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"pattern": [
|
||||
"SRS",
|
||||
"RCR",
|
||||
"SRS"
|
||||
],
|
||||
"key": {
|
||||
"S": {
|
||||
"tag": "forge:plates/iron"
|
||||
},
|
||||
"C": {
|
||||
"item": "create:andesite_alloy"
|
||||
},
|
||||
"R": {
|
||||
"item": "minecraft:redstone"
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"item": "steampowered:multimeter",
|
||||
"count": 1
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue