Skip to content

Commit e5b09b9

Browse files
committed
feat(quantumchest): 添加量子箱相关功能并优化音效- 为多个方块添加音效类型方法
- 实现量子箱的物品耐久条渲染 - 添加背包模块的混入类(使林业背包支持粗矿) - 合并PR:GregTechCEu#2853 - 合并PR:GregTechCEu#2853
1 parent d18c5fe commit e5b09b9

23 files changed

Lines changed: 242 additions & 29 deletions

src/main/java/gregtech/api/block/machines/BlockMachine.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,4 +596,13 @@ public void randomDisplayTick(@NotNull IBlockState stateIn, @NotNull World world
596596
MetaTileEntity metaTileEntity = getMetaTileEntity(worldIn, pos);
597597
if (metaTileEntity != null) metaTileEntity.randomDisplayTick();
598598
}
599+
600+
@NotNull
601+
@Override
602+
public SoundType getSoundType(@NotNull IBlockState state, @NotNull World world, @NotNull BlockPos pos,
603+
@Nullable Entity entity) {
604+
MetaTileEntity metaTileEntity = getMetaTileEntity(world, pos);
605+
if (metaTileEntity == null) return getSoundType();
606+
return metaTileEntity.getSoundType();
607+
}
599608
}

src/main/java/gregtech/api/capability/impl/AbstractRecipeLogic.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,10 @@ protected boolean hasEnoughPower(long eut, int duration) {
880880
if (eut >= 0) {
881881
// Power Consumption case
882882
// ensure it can run for at least 8 ticks. Arbitrary value, but should prevent instant failures
883-
return getEnergyStored() >= (eut << 3);
883+
//return getEnergyStored() >= (eut << 3);
884+
885+
//why 8tick
886+
return getEnergyStored() >= eut;
884887
} else {
885888
// Power Generation case
886889
// Return true if we can fit at least 1A of energy into the energy output

src/main/java/gregtech/api/metatileentity/MetaTileEntity.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import gregtech.common.items.MetaItems;
4242

4343
import net.minecraft.block.Block;
44+
import net.minecraft.block.SoundType;
4445
import net.minecraft.block.state.BlockFaceShape;
4546
import net.minecraft.block.state.IBlockState;
4647
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
@@ -919,6 +920,13 @@ private void updateSound() {
919920
return registry.getBlock();
920921
}
921922

923+
/**
924+
* @return The sound type used when this block is broken, placed, stepped on, hit, or fallen on.
925+
*/
926+
@NotNull
927+
public SoundType getSoundType() {
928+
return SoundType.METAL;
929+
}
922930
/**
923931
* Add special drops which this meta tile entity contains here
924932
* Meta tile entity item is ALREADY added into this list

src/main/java/gregtech/api/metatileentity/registry/MBPattern.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import gregtech.api.pattern.TraceabilityPredicate;
44
import gregtech.client.renderer.scene.VBOWorldSceneRenderer;
5-
import gregtech.client.renderer.scene.WorldSceneRenderer;
65

76
import net.minecraft.item.ItemStack;
87
import net.minecraft.util.math.BlockPos;

src/main/java/gregtech/api/pipenet/block/BlockPipe.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,15 @@ public static Cuboid6 getCoverSideBox(EnumFacing side, float thickness) {
136136

137137
public abstract ItemStack getDropItem(IPipeTile<PipeType, NodeDataType> pipeTile);
138138

139+
@NotNull
140+
@Override
141+
@SuppressWarnings({ "deprecation", "rawtypes", "unchecked" })
142+
public ItemStack getItem(@NotNull World world, @NotNull BlockPos pos, @NotNull IBlockState state) {
143+
var te = world.getTileEntity(pos);
144+
if (!(te instanceof IPipeTile pipeTile)) return ItemStack.EMPTY;
145+
return getDropItem((IPipeTile<PipeType, NodeDataType>) pipeTile);
146+
}
147+
139148
protected abstract NodeDataType getFallbackType();
140149

141150
// TODO this has no reason to need an ItemStack parameter

src/main/java/gregtech/common/metatileentities/MetaTileEntityClipboard.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import gregtech.core.network.packets.PacketClipboardNBTUpdate;
2222

2323
import net.minecraft.block.Block;
24+
import net.minecraft.block.SoundType;
2425
import net.minecraft.block.state.IBlockState;
2526
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
2627
import net.minecraft.creativetab.CreativeTabs;
@@ -548,4 +549,10 @@ public boolean showToolUsages() {
548549
public ItemStack getPickItem(EntityPlayer player) {
549550
return this.getClipboard();
550551
}
552+
553+
@NotNull
554+
@Override
555+
public SoundType getSoundType() {
556+
return SoundType.WOOD;
557+
}
551558
}

src/main/java/gregtech/common/metatileentities/multi/MetaTileEntityCokeOven.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import gregtech.common.metatileentities.MetaTileEntities;
2424
import gregtech.common.mui.widget.GTFluidSlot;
2525

26+
import net.minecraft.block.SoundType;
2627
import net.minecraft.block.state.IBlockState;
2728
import net.minecraft.entity.player.EntityPlayer;
2829
import net.minecraft.entity.player.EntityPlayerMP;
@@ -175,4 +176,10 @@ public boolean onRightClick(EntityPlayer playerIn, EnumHand hand, EnumFacing fac
175176
}
176177
return super.onRightClick(playerIn, hand, facing, hitResult);
177178
}
179+
180+
@NotNull
181+
@Override
182+
public SoundType getSoundType() {
183+
return SoundType.STONE;
184+
}
178185
}

src/main/java/gregtech/common/metatileentities/multi/MetaTileEntityCokeOvenHatch.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import gregtech.client.renderer.texture.Textures;
1313
import gregtech.common.metatileentities.multi.multiblockpart.MetaTileEntityMultiblockPart;
1414

15+
import net.minecraft.block.SoundType;
1516
import net.minecraft.client.resources.I18n;
1617
import net.minecraft.entity.player.EntityPlayer;
1718
import net.minecraft.item.ItemStack;
@@ -30,6 +31,7 @@
3031
import codechicken.lib.render.CCRenderState;
3132
import codechicken.lib.render.pipeline.IVertexOperation;
3233
import codechicken.lib.vec.Matrix4;
34+
import org.jetbrains.annotations.NotNull;
3335
import org.jetbrains.annotations.Nullable;
3436

3537
import java.util.List;
@@ -127,4 +129,11 @@ public boolean onRightClick(EntityPlayer playerIn, EnumHand hand, EnumFacing fac
127129
}
128130
return super.onRightClick(playerIn, hand, facing, hitResult);
129131
}
132+
133+
134+
@NotNull
135+
@Override
136+
public SoundType getSoundType() {
137+
return SoundType.STONE;
138+
}
130139
}

src/main/java/gregtech/common/metatileentities/multi/MetaTileEntityMultiblockTank.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import gregtech.common.metatileentities.MetaTileEntities;
2121
import gregtech.common.mui.widget.GTFluidSlot;
2222

23+
import net.minecraft.block.SoundType;
2324
import net.minecraft.block.state.IBlockState;
2425
import net.minecraft.client.resources.I18n;
2526
import net.minecraft.entity.player.EntityPlayer;
@@ -191,4 +192,11 @@ public <T> T getCapability(Capability<T> capability, EnumFacing side) {
191192
}
192193
return super.getCapability(capability, side);
193194
}
195+
196+
197+
@NotNull
198+
@Override
199+
public SoundType getSoundType() {
200+
return this.isMetal ? SoundType.METAL : SoundType.WOOD;
201+
}
194202
}

src/main/java/gregtech/common/metatileentities/multi/MetaTileEntityPrimitiveBlastFurnace.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import gregtech.common.blocks.BlockMetalCasing;
2626
import gregtech.common.blocks.MetaBlocks;
2727

28+
import net.minecraft.block.SoundType;
2829
import net.minecraft.block.state.IBlockState;
2930
import net.minecraft.entity.EntityLivingBase;
3031
import net.minecraft.init.SoundEvents;
@@ -225,4 +226,11 @@ public void randomDisplayTick() {
225226
}
226227
}
227228
}
229+
230+
231+
@NotNull
232+
@Override
233+
public SoundType getSoundType() {
234+
return SoundType.STONE;
235+
}
228236
}

0 commit comments

Comments
 (0)