Skip to content

Commit

Permalink
internal: move electrotine generator to PR Core
Browse files Browse the repository at this point in the history
  • Loading branch information
MrTJP committed Nov 21, 2022
1 parent 33c0d14 commit 79abe92
Show file tree
Hide file tree
Showing 34 changed files with 752 additions and 473 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"variants": {
"charged=false,rotation=0,working=false": {
"model": "projectred-core:block/electrotine_generator"
},
"charged=true,rotation=0,working=false": {
"model": "projectred-core:block/electrotine_generator_state1"
},
"charged=false,rotation=1,working=false": {
"model": "projectred-core:block/electrotine_generator",
"y": 90
},
"charged=true,rotation=1,working=false": {
"model": "projectred-core:block/electrotine_generator_state1",
"y": 90
},
"charged=false,rotation=2,working=false": {
"model": "projectred-core:block/electrotine_generator",
"y": 180
},
"charged=true,rotation=2,working=false": {
"model": "projectred-core:block/electrotine_generator_state1",
"y": 180
},
"charged=false,rotation=3,working=false": {
"model": "projectred-core:block/electrotine_generator",
"y": 270
},
"charged=true,rotation=3,working=false": {
"model": "projectred-core:block/electrotine_generator_state1",
"y": 270
},
"charged=false,rotation=0,working=true": {
"model": "projectred-core:block/electrotine_generator_state2"
},
"charged=true,rotation=0,working=true": {
"model": "projectred-core:block/electrotine_generator_state3"
},
"charged=false,rotation=1,working=true": {
"model": "projectred-core:block/electrotine_generator_state2",
"y": 90
},
"charged=true,rotation=1,working=true": {
"model": "projectred-core:block/electrotine_generator_state3",
"y": 90
},
"charged=false,rotation=2,working=true": {
"model": "projectred-core:block/electrotine_generator_state2",
"y": 180
},
"charged=true,rotation=2,working=true": {
"model": "projectred-core:block/electrotine_generator_state3",
"y": 180
},
"charged=false,rotation=3,working=true": {
"model": "projectred-core:block/electrotine_generator_state2",
"y": 270
},
"charged=true,rotation=3,working=true": {
"model": "projectred-core:block/electrotine_generator_state3",
"y": 270
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"parent": "minecraft:block/orientable_with_bottom",
"textures": {
"side": "projectred-core:block/electrotine_generator_side",
"front": "projectred-core:block/electrotine_generator_front_0",
"bottom": "projectred-core:block/electrotine_generator_bottom",
"top": "projectred-core:block/electrotine_generator_top"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"parent": "minecraft:block/orientable_with_bottom",
"textures": {
"side": "projectred-core:block/electrotine_generator_side",
"front": "projectred-core:block/electrotine_generator_front_1",
"bottom": "projectred-core:block/electrotine_generator_bottom",
"top": "projectred-core:block/electrotine_generator_top"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"parent": "minecraft:block/orientable_with_bottom",
"textures": {
"side": "projectred-core:block/electrotine_generator_side",
"front": "projectred-core:block/electrotine_generator_front_2",
"bottom": "projectred-core:block/electrotine_generator_bottom",
"top": "projectred-core:block/electrotine_generator_top"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"parent": "minecraft:block/orientable_with_bottom",
"textures": {
"side": "projectred-core:block/electrotine_generator_side",
"front": "projectred-core:block/electrotine_generator_front_3",
"bottom": "projectred-core:block/electrotine_generator_bottom",
"top": "projectred-core:block/electrotine_generator_top"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "projectred-core:block/electrotine_generator"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"type": "minecraft:crafting_shaped",
"result": {
"item": "projectred-core:electrotine_generator"
},
"pattern": [
"bbb",
"bdb",
"cec"
],
"key": {
"c": {
"item": "minecraft:clay"
},
"e": {
"tag": "forge:ingots/electrotine_alloy"
},
"d": {
"tag": "forge:dusts/electrotine"
},
"b": {
"item": "minecraft:bricks"
}
}
}
3 changes: 1 addition & 2 deletions src/core/resources/assets/projectred-core/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"itemGroup.projectred-compatibility": "Project Red: Compatibility",
"itemGroup.projectred-relocation": "Project Red: Relocation",


"item.projectred-core.plate": "Circuit Plate",
"item.projectred-core.conductive_plate": "Conductive Plate",
"item.projectred-core.wired_plate": "Wired Plate",
Expand Down Expand Up @@ -68,6 +67,7 @@
"item.projectred-core.multimeter": "Multimeter",
"item.projectred-core.screwdriver": "Screwdriver",
"item.projectred-core.router_utility": "Router Utility",
"block.projectred-core.electrotine_generator": "Electrotine Generator",


"item.projectred-expansion.empty_battery": "Battery",
Expand All @@ -78,7 +78,6 @@
"item.projectred-expansion.plan": "Recipe Plan",
"item.projectred-expansion.solar_panel": "Solar Panel",
"block.projectred-expansion.induction_furnace": "Inductive Furnace",
"block.projectred-expansion.electrotine_generator": "Electrotine Generator",
"block.projectred-expansion.block_breaker": "Block Breaker",
"block.projectred-expansion.item_importer": "Item Importer",
"block.projectred-expansion.block_placer": "Block Placer",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package mrtjp.projectred.core.block;

import codechicken.lib.vec.Rotation;
import mrtjp.projectred.core.tile.ElectrotineGeneratorTile;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.material.Material;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.state.StateContainer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockReader;

import javax.annotation.Nullable;

public class ElectrotineGeneratorBlock extends ProjectRedBlock {

public ElectrotineGeneratorBlock() {
super(AbstractBlock.Properties.of(Material.STONE));
}

@Override
protected TileEntity createTileEntityInstance(BlockState state, IBlockReader world) {
return new ElectrotineGeneratorTile();
}

@Nullable
@Override
public BlockState getStateForPlacement(BlockItemUseContext context) {
int r = Rotation.rotationTo(0, context.getHorizontalDirection().ordinal());
return this.defaultBlockState()
.setValue(ROTATION, r)
.setValue(CHARGED, false)
.setValue(WORKING, false);
}

@Override
protected void createBlockStateDefinition(StateContainer.Builder<Block, BlockState> builder) {
builder.add(ROTATION);
builder.add(CHARGED);
builder.add(WORKING);
}
}
86 changes: 86 additions & 0 deletions src/core/scala/mrtjp/projectred/core/block/ProjectRedBlock.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package mrtjp.projectred.core.block;

import mrtjp.projectred.core.tile.IBlockEventTile;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.state.BooleanProperty;
import net.minecraft.state.IntegerProperty;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;

import javax.annotation.Nullable;

public abstract class ProjectRedBlock extends Block {

public static final IntegerProperty SIDE = IntegerProperty.create("side", 0, 5);
public static final IntegerProperty ROTATION = IntegerProperty.create("rotation", 0, 3);
public static final BooleanProperty CHARGED = BooleanProperty.create("charged");
public static final BooleanProperty WORKING = BooleanProperty.create("working");

public ProjectRedBlock(AbstractBlock.Properties properties) {
super(properties);
}

protected abstract TileEntity createTileEntityInstance(BlockState state, IBlockReader world);

@Override
public boolean hasTileEntity(BlockState state) {
return true;
}

@Nullable
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
TileEntity tile = createTileEntityInstance(state, world);
if (tile instanceof IBlockEventTile) ((IBlockEventTile) tile).loadBlockState(state);
return tile;
}

@Override
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos neighbor, boolean isMoving) {
TileEntity tile = world.getBlockEntity(pos);
if (tile instanceof IBlockEventTile) ((IBlockEventTile) tile).onNeighborBlockChanged(neighbor);
}

@Override
public void onNeighborChange(BlockState state, IWorldReader world, BlockPos pos, BlockPos neighbor) {
TileEntity tile = world.getBlockEntity(pos);
if (tile instanceof IBlockEventTile) ((IBlockEventTile) tile).onNeighborTileChanged(neighbor);
}

@Override
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
TileEntity tile = world.getBlockEntity(pos);
if (tile instanceof IBlockEventTile) return ((IBlockEventTile) tile).onBlockActivated(player, hand, hit);
return ActionResultType.FAIL; //TODO pass?
}

@Override
public void onRemove(BlockState oldState, World world, BlockPos pos, BlockState newState, boolean isMoving) {
TileEntity tile = world.getBlockEntity(pos);
if (tile instanceof IBlockEventTile) {
if (oldState.is(newState.getBlock())) {
((IBlockEventTile) tile).onBlockStateReplaced(newState);
} else {
((IBlockEventTile) tile).onBlockRemoved();
}
}
super.onRemove(oldState, world, pos, newState, isMoving); // Removes tile if no longer valid for new state
}

@Override
public void setPlacedBy(World world, BlockPos pos, BlockState state, @Nullable LivingEntity player, ItemStack stack) {
TileEntity tile = world.getBlockEntity(pos);
if (tile instanceof IBlockEventTile) ((IBlockEventTile) tile).onBlockPlaced(player, stack);
}
}
Loading

0 comments on commit 79abe92

Please sign in to comment.