Skip to content

Commit

Permalink
Tweaked meteor showers.
Browse files Browse the repository at this point in the history
Added Storage Containers.
  • Loading branch information
MartinSVK12 committed Apr 7, 2024
1 parent c15ce70 commit 897384d
Show file tree
Hide file tree
Showing 18 changed files with 798 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@

import net.fabricmc.api.ModInitializer;

import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.fx.EntityFX;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.options.components.KeyBindingComponent;
import net.minecraft.client.gui.options.components.OptionsCategory;
import net.minecraft.client.gui.options.data.OptionsPages;
import net.minecraft.client.render.FontRenderer;
import net.minecraft.client.render.block.model.BlockModelDispatcher;
import net.minecraft.client.render.block.model.BlockModelRenderBlocks;
import net.minecraft.client.render.entity.FallingSandRenderer;
import net.minecraft.client.render.entity.MobRenderer;
import net.minecraft.client.render.entity.SnowballRenderer;
import net.minecraft.client.render.model.ModelZombie;
Expand All @@ -27,6 +26,7 @@
import net.minecraft.core.item.material.ArmorMaterial;
import net.minecraft.core.item.material.ToolMaterial;
import net.minecraft.core.item.tool.ItemToolPickaxe;
import net.minecraft.core.lang.I18n;
import net.minecraft.core.player.inventory.Container;
import net.minecraft.core.player.inventory.IInventory;
import net.minecraft.core.sound.BlockSounds;
Expand Down Expand Up @@ -672,6 +672,37 @@ public class SignalIndustries implements ModInitializer, GameStartEntrypoint {
.setNorthTexture("basic_assembler_front.png")
.build(new BlockAssembler("basic.assembler",config.getInt("BlockIDs.basicAssembler"), Tier.BASIC, Material.metal));

public static final Block prototypeStorageContainer = new BlockBuilder(MOD_ID)
.setHardness(1)
.setResistance(3)
.setBlockSound(BlockSounds.STONE)
.setTextures("prototype_blank.png")
.setNorthTexture("container_prototype_front.png")
.build(new BlockStorageContainer("prototype.storageContainer",config.getInt("BlockIDs.prototypeStorageContainer"), Tier.PROTOTYPE, Material.stone));

public static final Block infiniteStorageContainer = new BlockBuilder(MOD_ID)
.setHardness(1)
.setResistance(3)
.setBlockSound(BlockSounds.STONE)
.setTextures("prototype_blank.png")
.setNorthTexture("container_prototype_front.png")
.build(new BlockStorageContainer("infinite.storageContainer",config.getInt("BlockIDs.infiniteStorageContainer"), Tier.INFINITE, Material.stone));

public static final Block basicStorageContainer = new BlockBuilder(MOD_ID)
.setHardness(1)
.setResistance(3)
.setBlockSound(BlockSounds.METAL)
.setTextures("basic_blank.png")
.setNorthTexture("container_basic_front.png")
.build(new BlockStorageContainer("basic.storageContainer",config.getInt("BlockIDs.basicStorageContainer"), Tier.BASIC, Material.metal));

public static final Block reinforcedStorageContainer = new BlockBuilder(MOD_ID)
.setHardness(1)
.setResistance(3)
.setBlockSound(BlockSounds.METAL)
.setTextures("reinforced_blank.png")
.setNorthTexture("container_reinforced_front.png")
.build(new BlockStorageContainer("reinforced.storageContainer",config.getInt("BlockIDs.reinforcedStorageContainer"), Tier.REINFORCED, Material.metal));

public static final Block basicWrathBeacon = new BlockBuilder(MOD_ID)
.setHardness(2)
Expand Down Expand Up @@ -1387,6 +1418,8 @@ private void addEntities(){
EntityHelper.Core.createSpecialTileEntity(TileEntityAssembler.class, new RenderAssemblerItemSprite3D(),"Assembler");
addToNameGuiMap("Assembler", GuiAssembler.class, TileEntityAssembler.class);

EntityHelper.Core.createSpecialTileEntity(TileEntityStorageContainer.class, new RenderStorageContainer(),"Storage Container");

EntityHelper.Core.createSpecialTileEntity(TileEntityDimensionalAnchor.class,new RenderMultiblock(),"Dimensional Anchor");
addToNameGuiMap("Dimensional Anchor", GuiDimAnchor.class, TileEntityDimensionalAnchor.class);

Expand Down Expand Up @@ -1580,6 +1613,60 @@ public static boolean hasItems(List<RecipeSymbol> symbols, List<ItemStack> avail
return s == sReq;
}

public static String[] splitStringIntoLines(FontRenderer fr, String string) {
String[] words = string.split(" ");
List<String> lines = new ArrayList<>();
StringBuilder line = new StringBuilder();
for (String word : words) {
if (fr.getStringWidth(line + " " + word) > 142) {
lines.add(line.toString());
line = new StringBuilder();
}
if (word.contains("\n")) {
String safeWord = word.replace("\r", "");
String[] wordParts = safeWord.split("\n");
for (int i = 0; i < wordParts.length; i++) {
if (i > 0) {
lines.add(line.toString());
line = new StringBuilder();
}
line.append(wordParts[i]).append(" ");
}
} else {
line.append(word).append(" ");
}
}
lines.add(line.toString());
return lines.toArray(new String[0]);
}

public static String[] splitStringIntoLines(FontRenderer fr, String string, int maxLength) {
String[] words = string.split(" ");
List<String> lines = new ArrayList<>();
StringBuilder line = new StringBuilder();
for (String word : words) {
if (fr.getStringWidth(line + " " + word) > maxLength) {
lines.add(line.toString());
line = new StringBuilder();
}
if (word.contains("\n")) {
String safeWord = word.replace("\r", "");
String[] wordParts = safeWord.split("\n");
for (int i = 0; i < wordParts.length; i++) {
if (i > 0) {
lines.add(line.toString());
line = new StringBuilder();
}
line.append(wordParts[i]).append(" ");
}
} else {
line.append(word).append(" ");
}
}
lines.add(line.toString());
return lines.toArray(new String[0]);
}

public static void usePortal(int dim) {
Minecraft mc = Minecraft.getMinecraft(Minecraft.class);
Dimension lastDim = Dimension.getDimensionList().get(mc.thePlayer.dimension);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ public void initializePlugin(TooltipRegistry tooltipRegistry, Logger logger) {
tooltipRegistry.register(new BoosterTooltip());
tooltipRegistry.register(new StabilizerTooltip());
tooltipRegistry.register(new ItemConduitTooltip());
tooltipRegistry.register(new StorageContainerTooltip());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package sunsetsatellite.signalindustries.api.impl.btwaila.tooltip;

import net.minecraft.core.block.Block;
import sunsetsatellite.signalindustries.SignalIndustries;
import sunsetsatellite.signalindustries.inventories.TileEntitySIFluidTank;
import sunsetsatellite.signalindustries.inventories.TileEntityStorageContainer;
import sunsetsatellite.signalindustries.inventories.base.TileEntityTieredMachineBase;
import toufoumaster.btwaila.gui.components.AdvancedInfoComponent;
import toufoumaster.btwaila.util.ProgressBarOptions;
import toufoumaster.btwaila.util.TextureOptions;

public class StorageContainerTooltip extends SIBaseTooltip<TileEntityStorageContainer> {
@Override
public void initTooltip() {
this.addClass(TileEntityStorageContainer.class);
}

@Override
public void drawAdvancedTooltip(TileEntityStorageContainer tile, AdvancedInfoComponent c) {
if(tile.contents != null){
int color = 0x00FF00;
float ratio = (float) tile.contents.stackSize / tile.capacity;
if(ratio >= 0.5f && ratio < 0.8f){
color = 0xFFFF00;
} else if (ratio >= 0.8f) {
color = 0xFF0000;
}
if(tile.locked){
c.drawStringWithShadow("Locked",0,0xFFFF00);
}
c.drawStringWithShadow("Holding: "+tile.contents.stackSize+"x "+tile.contents.getDisplayName(),0);
ProgressBarOptions options = new ProgressBarOptions()
.setForegroundOptions(new TextureOptions(color, Block.sand.atlasIndices[0]))
.setBackgroundOptions(new TextureOptions(0, SignalIndustries.realityFabric.atlasIndices[0]))
.setText("Capacity: ");
c.drawProgressBarTextureWithText(tile.contents.stackSize,tile.capacity,options,0);
} else {
if(tile.locked){
c.drawStringWithShadow("Locked",0,0xFFFF00);
}
c.drawStringWithShadow("Empty",0);
ProgressBarOptions options = new ProgressBarOptions()
.setForegroundOptions(new TextureOptions(0x00FF00, Block.sand.atlasIndices[0]))
.setBackgroundOptions(new TextureOptions(0, SignalIndustries.realityFabric.atlasIndices[0]))
.setText("Capacity: ");
c.drawProgressBarTextureWithText(0,tile.capacity,options,0);
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
package sunsetsatellite.signalindustries.blocks;


import net.minecraft.core.block.entity.TileEntity;
import net.minecraft.core.block.material.Material;
import net.minecraft.core.entity.EntityItem;
import net.minecraft.core.entity.player.EntityPlayer;
import net.minecraft.core.item.ItemStack;
import net.minecraft.core.item.tool.ItemTool;
import net.minecraft.core.player.gamemode.Gamemode;
import net.minecraft.core.util.helper.Side;
import net.minecraft.core.util.helper.Sides;
import net.minecraft.core.world.World;
import net.minecraft.core.world.WorldSource;
import sunsetsatellite.catalyst.core.util.Direction;
import sunsetsatellite.catalyst.core.util.Vec3f;
import sunsetsatellite.signalindustries.SignalIndustries;
import sunsetsatellite.signalindustries.blocks.base.BlockContainerTiered;
import sunsetsatellite.signalindustries.inventories.TileEntityStorageContainer;
import sunsetsatellite.signalindustries.util.Tier;

import java.util.Random;

public class BlockStorageContainer extends BlockContainerTiered {
public BlockStorageContainer(String key, int i, Tier tier, Material material) {
super(key, i, tier, material);
withTags(SignalIndustries.ITEM_CONDUITS_CONNECT);
}

@Override
protected TileEntity getNewBlockEntity() {
return new TileEntityStorageContainer();
}

@Override
public void onBlockRemoved(World world, int i, int j, int k, int data) {
TileEntityStorageContainer tile = (TileEntityStorageContainer) world.getBlockTileEntity(i, j, k);
if (tile != null && tile.contents != null && tier != Tier.INFINITE) {
Random random = new Random();
float f = random.nextFloat() * 0.8F + 0.1F;
float f1 = random.nextFloat() * 0.8F + 0.1F;
float f2 = random.nextFloat() * 0.8F + 0.1F;
EntityItem entityitem = new EntityItem(world, (float) i + f, (float) j + f1, (float) k + f2, tile.contents.copy());
float f3 = 0.05F;
entityitem.xd = (float) random.nextGaussian() * f3;
entityitem.yd = (float) random.nextGaussian() * f3 + 0.2F;
entityitem.zd = (float) random.nextGaussian() * f3;
world.entityJoinedWorld(entityitem);
}
super.onBlockRemoved(world, i, j, k, data);
}

@Override
public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) {
super.onBlockClicked(world, x, y, z, player);
TileEntityStorageContainer tile = (TileEntityStorageContainer) world.getBlockTileEntity(x, y, z);
if (tile != null) {
if(player.getCurrentEquippedItem() == null || !(player.getCurrentEquippedItem().getItem() instanceof ItemTool)){
ItemStack stack;
if(!player.isSneaking()){
stack = tile.extractStack(1);
} else {
stack = tile.extractStack();
}
if(stack != null){
Vec3f vec = new Vec3f(x,y,z).add(Direction.getDirectionFromSide(world.getBlockMetadata(x,y,z)).getVecF()).add(0.5f);
EntityItem entityitem = new EntityItem(world, vec.x, vec.y, vec.z, stack);
world.entityJoinedWorld(entityitem);
}
}
}
}

@Override
public boolean blockActivated(World world, int i, int j, int k, EntityPlayer player)
{
TileEntityStorageContainer tile = (TileEntityStorageContainer) world.getBlockTileEntity(i, j, k);
if (tile != null) {
if(player.getCurrentEquippedItem() != null) {
if (player.getCurrentEquippedItem().animationsToGo <= 0) {
ItemStack stack = player.getCurrentEquippedItem().copy();
stack.stackSize = 1;
if(tile.insertStack(stack)){
player.getCurrentEquippedItem().stackSize--;
if(player.getCurrentEquippedItem().stackSize <= 0){
player.destroyCurrentEquippedItem();
} else {
player.getCurrentEquippedItem().animationsToGo = 5;
}
}
} else {
tile.insertStack(player.getCurrentEquippedItem());
if(player.getCurrentEquippedItem().stackSize <= 0){
player.destroyCurrentEquippedItem();
} else {
player.getCurrentEquippedItem().animationsToGo = 5;
}
}
return true;
} else {
if(tile.infinite && player.gamemode == Gamemode.creative){
tile.contents = null;
} else {
tile.locked = !tile.locked;
if(tile.locked){
player.addChatMessage("event.signalindustries.containerLocked");
} else {
player.addChatMessage("event.signalindustries.containerUnlocked");
}
}
}
}
return false;
}

@Override
public int getBlockTexture(WorldSource blockAccess, int x, int y, int z, Side side) {
int meta = blockAccess.getBlockMetadata(x,y,z);
int index = Sides.orientationLookUpHorizontal[6 * meta + side.getId()];
return this.atlasIndices[index];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ public EntityFallingMeteor(World world, int blockId) {
this.setSize(0.5f, 0.5f);
}

@Override
public boolean shouldRenderAtSqrDistance(double distance) {
return true;
}

public EntityFallingMeteor(World world, double d, double d1, double d2, int blockId) {
super(world);
this.doesArrowBelongToPlayer = false;
Expand All @@ -78,9 +83,9 @@ public EntityFallingMeteor(World world, double d, double d1, double d2, int bloc
this.heightOffset = 0.0f;
this.yd = -0.75f;
if(random.nextFloat() > 0.5f){
this.xd = random.nextFloat() - 0.5f;
this.xd = (random.nextFloat()+1) - 1f;
} else {
this.zd = random.nextFloat() - 0.5f;
this.zd = (random.nextFloat()+1) - 1f;
}
this.setArrowHeading(this.xd, this.yd, this.zd, 1f, 1.0f);
}
Expand Down Expand Up @@ -195,9 +200,9 @@ public void tick() {
}

for (int j = 0; j < 4; j++) {
SignalIndustries.spawnParticle(new EntityMeteorTailFX(this.world,this.x + 0.5f, this.y, this.z + 0.5f, this.xd * (double)0.05f, this.yd * (double)0.05f - (double)0.1f, this.zd * (double)0.05f,1).setFullbright(true).setBlockId(blockID),32);
SignalIndustries.spawnParticle(new EntityMeteorTailFX(this.world,this.x + 0.5f, this.y, this.z + 0.5f, this.xd * (double)0.05f, this.yd * (double)0.05f - (double)0.1f, this.zd * (double)0.05f,1).setFullbright(true).setBlockId(blockID),256);
}
SignalIndustries.spawnParticle(new EntityMeteorTailFX(this.world,this.x + 0.5f, this.y, this.z + 0.5f, this.xd * (double)0.05f, this.yd * (double)0.05f - (double)0.1f, this.zd * (double)0.05f,1).setFullbright(true).setBlockId(blockID),32);
SignalIndustries.spawnParticle(new EntityMeteorTailFX(this.world,this.x + 0.5f, this.y, this.z + 0.5f, this.xd * (double)0.05f, this.yd * (double)0.05f - (double)0.1f, this.zd * (double)0.05f,1).setFullbright(true).setBlockId(blockID),256);
//SignalIndustries.spawnParticle(new EntityColorParticleFX(this.world,this.x + this.xd * 0.5, this.y + this.yd * 0.5, this.z + this.zd * 0.5, this.xd * (double)0.05f, this.yd * (double)0.05f - (double)0.1f, this.zd * (double)0.05f,1,1f,1f,0.2f));
++this.ticksInAir;
Vec3d oldPos = Vec3d.createVector(this.x, this.y, this.z);
Expand Down
Loading

0 comments on commit 897384d

Please sign in to comment.