Skip to content

Commit

Permalink
version 1.1b of the mod
Browse files Browse the repository at this point in the history
  • Loading branch information
george8188625 committed Jul 19, 2023
1 parent 55d9aec commit 3dbdf15
Show file tree
Hide file tree
Showing 40 changed files with 647 additions and 230 deletions.
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,4 @@ build

# other
eclipse
run

# Files from Forge MDK
changelog.txt
run
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 George VI

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<h1 align="center">Create Diesel Generators</h1>
<p align="center">
<a href="https://modrinth.com/mod/create-diesel-generators"><img src="https://img.shields.io/modrinth/dt/create-diesel-generators?logo=modrinth&label=&suffix=%20&style=flat&color=242629&labelColor=5ca424&logoColor=1c1c1c"></a>
<a href="https://www.curseforge.com/minecraft/mc-mods/create-diesel-generators"><img src="https://cf.way2muchnoise.eu/869316.svg"></a>
<a href="https://discord.gg/pUgaSXcGEQ"><img src="https://img.shields.io/discord/1121792423836799128?color=5865f2&label=Discord"></a><br>
Adding Diesel Generators ( and more stuff ) to the <a href="https://www.curseforge.com/minecraft/mc-mods/create">Create</a> mod.
<br><br><br><br>
<img src="">
<img src="https://cdn.discordapp.com/emojis/1121801687502434525.png?size=48&quality=lossless">
<img src="https://cdn.discordapp.com/emojis/1121802680143204452.png?size=48&quality=lossless">
<img src="https://cdn.discordapp.com/emojis/1123310184194904245.png?size=48&quality=lossless">
<img src="https://cdn.discordapp.com/emojis/1122645482825580664.png?size=48&quality=lossless">
<img src="https://cdn.discordapp.com/emojis/1121801687502434525.png?size=48&quality=lossless">
<img src="https://cdn.discordapp.com/emojis/1121802680143204452.png?size=48&quality=lossless">
<img src="https://cdn.discordapp.com/emojis/1123310184194904245.png?size=48&quality=lossless">
<img src="https://cdn.discordapp.com/emojis/1122645482825580664.png?size=48&quality=lossless">
<img src="https://cdn.discordapp.com/emojis/1121801687502434525.png?size=48&quality=lossless">
<img src="https://cdn.discordapp.com/emojis/1121802680143204452.png?size=48&quality=lossless">

</p>

2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {

}

version = '1.19.2-1.1'
version = '1.19.2-1.1b'
group = 'com.jesz.createdieselgenerators' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'createdieselgenerators'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@

import com.jesz.createdieselgenerators.blocks.BlockRegistry;
import com.jesz.createdieselgenerators.blocks.entity.BlockEntityRegistry;
import com.jesz.createdieselgenerators.config.ConfigRegistry;
import com.jesz.createdieselgenerators.fluids.FluidRegistry;
import com.jesz.createdieselgenerators.items.ItemRegistry;
import com.jesz.createdieselgenerators.ponder.PonderIndex;
import com.jesz.createdieselgenerators.recipes.RecipeRegistry;
import com.simibubi.create.Create;
import com.simibubi.create.foundation.data.CreateRegistrate;
import com.simibubi.create.foundation.utility.Components;
import net.minecraft.client.renderer.ItemBlockRenderTypes;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.world.level.material.Fluid;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;

import static com.simibubi.create.foundation.utility.Lang.resolveBuilders;
Expand All @@ -33,13 +33,15 @@ public CreateDieselGenerators()
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
IEventBus forgeEventBus = MinecraftForge.EVENT_BUS;

ItemRegistry.register(modEventBus);

ItemRegistry.register();
BlockRegistry.register();
FluidRegistry.register();
BlockEntityRegistry.register();
RecipeRegistry.register(modEventBus);
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> onClient(modEventBus, forgeEventBus));

ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, ConfigRegistry.SERVER_SPEC, "createdieselgenerators-server.toml");
MinecraftForge.EVENT_BUS.register(this);
REGISTRATE.registerEventListeners(modEventBus);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.DirectionProperty;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
Expand Down Expand Up @@ -58,6 +59,25 @@ public VoxelShape getShape(BlockState pState, BlockGetter pLevel, BlockPos pPos,
return Shapes.or(Block.box(14, 0, 0, 16, 16, 16),
Block.box(16, 5, 5, 18, 11, 11));

}
@Override
public void neighborChanged(BlockState state, Level level, BlockPos pos, Block block, BlockPos p_57551_, boolean p_57552_) {
if (!level.isClientSide) {
boolean flag = level.hasNeighborSignal(pos);
if (flag != state.getValue(OPEN)) {
if (state.getValue(OPEN) != flag) {
state = state.setValue(OPEN, flag);
level.levelEvent(null, flag ? 1037:1036, pos, 0);
}

level.setBlock(pos, state.setValue(OPEN, flag), 2);
if (state.getValue(WATERLOGGED)) {
level.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(level));
}
}

}

}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
package com.jesz.createdieselgenerators.blocks;

import com.jesz.createdieselgenerators.CreativeTab;
import com.jesz.createdieselgenerators.other.EngineStateDisplaySource;
import com.simibubi.create.content.redstone.displayLink.source.BoilerDisplaySource;
import com.simibubi.create.foundation.data.BlockStateGen;
import com.tterrag.registrate.util.entry.BlockEntry;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.material.MaterialColor;

import static com.jesz.createdieselgenerators.CreateDieselGenerators.REGISTRATE;
import static com.simibubi.create.content.redstone.displayLink.AllDisplayBehaviours.assignDataBehaviour;
import static com.simibubi.create.foundation.data.ModelGen.customItemModel;

public class BlockRegistry {
static {
static {
REGISTRATE.creativeModeTab(() -> CreativeTab.CREATIVE_TAB);
}
public static final BlockEntry<DieselGeneratorBlock> DIESEL_ENGINE = REGISTRATE.block("diesel_engine", DieselGeneratorBlock::new)
.properties(p -> p.color(MaterialColor.COLOR_YELLOW))
.properties(p -> p.sound(SoundType.NETHERITE_BLOCK))
.onRegister(assignDataBehaviour(new EngineStateDisplaySource()))
.properties(p -> p.noOcclusion())
.properties(p -> p.strength(3f))
.blockstate(BlockStateGen.horizontalBlockProvider(true))
Expand All @@ -26,14 +30,15 @@ public class BlockRegistry {
public static final BlockEntry<LargeDieselGeneratorBlock> MODULAR_DIESEL_ENGINE = REGISTRATE.block("large_diesel_engine", LargeDieselGeneratorBlock::new)
.properties(p -> p.color(MaterialColor.COLOR_YELLOW))
.properties(p -> p.sound(SoundType.NETHERITE_BLOCK))
.onRegister(assignDataBehaviour(new EngineStateDisplaySource()))
.properties(p -> p.noOcclusion())
.properties(p -> p.strength(3f))
.blockstate(BlockStateGen.horizontalBlockProvider(true))
.item()
.transform(customItemModel("_", "block"))
.register();
public static final BlockEntry<BasinLidBlock> BASIN_LID = REGISTRATE.block("basin_lid", BasinLidBlock::new)
.properties(p -> p.color(MaterialColor.COLOR_BLACK))
.properties(p -> p.color(MaterialColor.COLOR_GRAY))
.properties(p -> p.sound(SoundType.NETHERITE_BLOCK))
.properties(p -> p.noOcclusion())
.properties(p -> p.strength(3f))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.jesz.createdieselgenerators.blocks;

import com.jesz.createdieselgenerators.blocks.entity.DieselGeneratorBlockEntity;
import com.jesz.createdieselgenerators.blocks.entity.BlockEntityRegistry;
import com.jesz.createdieselgenerators.blocks.entity.DieselGeneratorBlockEntity;
import com.simibubi.create.content.kinetics.base.DirectionalKineticBlock;
import com.simibubi.create.foundation.block.IBE;
import com.simibubi.create.foundation.block.ProperWaterloggedBlock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@

import com.jesz.createdieselgenerators.blocks.entity.LargeDieselGeneratorBlockEntity;
import com.jesz.createdieselgenerators.blocks.entity.BlockEntityRegistry;
import com.simibubi.create.content.kinetics.base.GeneratingKineticBlockEntity;
import com.simibubi.create.content.kinetics.base.HorizontalKineticBlock;
import com.simibubi.create.content.kinetics.base.KineticBlockEntity;
import com.simibubi.create.foundation.block.IBE;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition.Builder;
Expand All @@ -36,6 +42,34 @@ public LargeDieselGeneratorBlock(Properties properties) {
registerDefaultState(super.defaultBlockState().setValue(PIPE, true));
}
@Override
public InteractionResult onWrenched(BlockState state, UseOnContext context) {
if(context.getClickedFace() == Direction.UP){
if(state.getValue(PIPE)) {
context.getLevel().setBlock(context.getClickedPos(), state.setValue(PIPE, false), 3);
}else{
context.getLevel().setBlock(context.getClickedPos(), state.setValue(PIPE, true), 3);
}
return InteractionResult.SUCCESS;
}
Level world = context.getLevel();
BlockState rotated = getRotatedBlockState(state, context.getClickedFace());
if (!rotated.canSurvive(world, context.getClickedPos()))
return InteractionResult.PASS;

KineticBlockEntity.switchToBlockState(world, context.getClickedPos(), updateAfterWrenched(rotated, context));

BlockEntity be = context.getLevel()
.getBlockEntity(context.getClickedPos());
if (be instanceof GeneratingKineticBlockEntity) {
((GeneratingKineticBlockEntity) be).reActivateSource = true;
}

if (world.getBlockState(context.getClickedPos()) != state)
playRotateSound(world, context.getClickedPos());

return InteractionResult.SUCCESS;
}
@Override
public BlockState getRotatedBlockState(BlockState originalState, Direction targetedFace) {
return originalState;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

public class BasinLidBlockEntity extends BasinOperatingBlockEntity {

public int procesingTime;
public int processingTime;
public boolean running;
public BasinLidBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type, pos, state);
Expand All @@ -29,21 +29,21 @@ public BasinLidBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState sta
@Override
protected void write(CompoundTag compound, boolean clientPacket) {
super.write(compound, clientPacket);
compound.putInt("MeltingTime", this.procesingTime);
compound.putInt("MeltingTime", this.processingTime);
compound.putBoolean("Running", this.running);
}

@Override
protected void read(CompoundTag compound, boolean clientPacket) {
super.read(compound, clientPacket);
this.procesingTime = compound.getInt("MeltingTime");
this.processingTime = compound.getInt("MeltingTime");
this.running = compound.getBoolean("Running");
}

@Override
protected void onBasinRemoved() {
if (!this.running) return;
this.procesingTime = 0;
this.processingTime = 0;
this.currentRecipe = null;
this.running = false;
}
Expand All @@ -58,20 +58,20 @@ public void tick() {
level.setBlock(getBlockPos(), getBlockState().setValue(ON_A_BASIN, basinPresent), 3);
}

if (!this.level.isClientSide && (this.currentRecipe == null || this.procesingTime == -1)) {
if (!this.level.isClientSide && (this.currentRecipe == null || this.processingTime == -1)) {
this.running = false;
this.procesingTime = -1;
this.processingTime = -1;
this.basinChecker.scheduleUpdate();
}

if (this.running && this.level != null) {
if (!this.level.isClientSide && this.procesingTime <= 0) {
this.procesingTime = -1;
if (!this.level.isClientSide && this.processingTime <= 0) {
this.processingTime = -1;
this.applyBasinRecipe();
this.sendData();
}

if (this.procesingTime > 0) --this.procesingTime;
if (this.processingTime > 0) --this.processingTime;
}
}

Expand All @@ -91,10 +91,10 @@ protected boolean updateBasin() {

@Override
public void startProcessingBasin() {
if (this.running && this.procesingTime > 0) return;
if (this.running && this.processingTime > 0) return;
super.startProcessingBasin();
this.running = true;
this.procesingTime = this.currentRecipe instanceof ProcessingRecipe<?> processed ? processed.getProcessingDuration() : 20;
this.processingTime = this.currentRecipe instanceof ProcessingRecipe<?> processed ? processed.getProcessingDuration() : 20;
}

@Override
Expand Down
Loading

0 comments on commit 3dbdf15

Please sign in to comment.