Add gas containers back, but wtf, why forge:steam is not registered?

This commit is contained in:
yuesha-yc 2021-10-29 00:00:00 -07:00
parent 94f06e5501
commit 2df15b9cce
No known key found for this signature in database
GPG key ID: 009D79A802D4ED01
8 changed files with 90 additions and 142 deletions

View file

@ -18,7 +18,7 @@ apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'org.spongepowered.mixin'
group = 'com.teammoeg'
version = '1.16.5-1.1.2'
version = '1.16.5-1.1.3'
java {
archivesBaseName = 'steampowered'

View file

@ -19,12 +19,13 @@
package com.teammoeg.steampowered;
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 Item(new Item.Properties()));
public static RegistryObject<Item> pressurizedSteamContainer = ITEMS.register("pressurized_steam_container", () -> new Item(new Item.Properties()));
}

View file

@ -22,25 +22,34 @@ import com.jozufozu.flywheel.core.PartialModel;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.AllShapes;
import com.simibubi.create.content.contraptions.components.flywheel.engine.EngineBlock;
import com.teammoeg.steampowered.FluidRegistry;
import com.teammoeg.steampowered.ItemRegistry;
import com.teammoeg.steampowered.registrate.SPTiles;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.particles.ParticleTypes;
import net.minecraft.state.BooleanProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
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.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import javax.annotation.Nullable;
import java.util.Random;
@ -103,4 +112,22 @@ public class SteamEngineBlock extends EngineBlock {
p_180655_2_.addParticle(ParticleTypes.LAVA, d0 + d5, d1 + d6, d2 + d7, 0.0D, 0.0D, 0.0D);
}
}
@Override
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult blockRayTraceResult) {
if (player.getItemInHand(hand).getItem() == ItemRegistry.pressurizedSteamContainer.get()) {
TileEntity te = world.getBlockEntity(pos);
if (te instanceof SteamEngineTileEntity) {
SteamEngineTileEntity steamEngine = (SteamEngineTileEntity) te;
IFluidHandler cap = steamEngine.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY).resolve().get();
cap.fill(new FluidStack(FluidRegistry.steam.get(), 1000), IFluidHandler.FluidAction.EXECUTE);
player.setItemInHand(hand, new ItemStack(ItemRegistry.pressurizedGasContainer.get()));
return ActionResultType.SUCCESS;
} else {
return ActionResultType.PASS;
}
} else {
return super.use(state, world, pos, player, hand, blockRayTraceResult);
}
}
}

View file

@ -1,134 +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.item;
import com.teammoeg.steampowered.FluidRegistry;
import com.teammoeg.steampowered.ItemRegistry;
import net.minecraft.advancements.CriteriaTriggers;
import net.minecraft.block.BlockState;
import net.minecraft.block.FlowingFluidBlock;
import net.minecraft.block.IBucketPickupHandler;
import net.minecraft.block.ILiquidContainer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.BucketItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Stats;
import net.minecraft.tags.FluidTags;
import net.minecraft.util.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import javax.annotation.Nullable;
public class GasContainerItem extends BucketItem {
public GasContainerItem(Fluid p_i49025_1_, Properties p_i49025_2_) {
super(p_i49025_1_, p_i49025_2_);
}
public GasContainerItem(java.util.function.Supplier<? extends Fluid> supplier, Item.Properties builder) {
super(supplier, builder);
}
// @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);
//
// // 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);
// }
// }
// }
// @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);
// }
}

View file

@ -4,9 +4,9 @@ license = "GPLv3"
issueTrackerURL = "https://github.com/TeamMoegMC/Steam-Powered/issues"
[[mods]] #mandatory
modId = "steampowered" #mandatory
version = "1.16.5-1.1.2" #mandatory
version = "1.16.5-1.1.3" #mandatory
displayName = "Create: Steam Powered" #mandatory
authors = "YueSha, khjxiaogu, goumo_g"
authors = "[TeamMoeg] YueSha, khjxiaogu, goumo_g"
credits = "We appreciate MRH0 for his code on RPM-FE conversion logic which we adapted in Steam Powered"
description = '''
Expanding Create mod to the Steam Age

View file

@ -0,0 +1,17 @@
{
"type": "create:emptying",
"ingredients": [
{
"item": "steampowered:pressurized_steam_container"
}
],
"results": [
{
"item": "steampowered:pressurized_gas_container"
},
{
"fluid": "steampowered:steam",
"amount": 1000
}
]
}

View file

@ -0,0 +1,17 @@
{
"type": "create:filling",
"ingredients": [
{
"item": "steampowered:pressurized_gas_container"
},
{
"fluidTag": "forge:steam",
"amount": 1000
}
],
"results": [
{
"item": "steampowered:pressurized_steam_container"
}
]
}

View file

@ -0,0 +1,20 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"SCS",
"SCS",
"SCS"
],
"key": {
"S": {
"tag": "forge:plates/copper"
},
"C": {
"tag": "forge:glass/colorless"
}
},
"result": {
"item": "steampowered:pressurized_gas_container",
"count": 2
}
}